By jsabater on
Hello everyone!
I am developing a module that adds a new type of content. So far it's working fine, but the thing is that I don't want, when adding new content of this type, that it becomes promoted to the front page. I would like it to be like the forums, which is a module that extends the node type, and when you post a new thread it does not appear in the front page.
I am trying to find out how the forums module does it, but so far I have not found it.
Anyone knows how to do it?
Thanks in advance.
Comments
It's done manually at
It's done manually at /admin/content/types. Just edit the content type of your choice and uncheck the option to promote nodes of that type by default.
What about automatically?
Erm... thanks, but I already knew that. :)
What I'd like to do is to do that automatically when the module is installed.
hook_form_alter
There may be a better way to do this, but I have done it in hook_form_alter, by manually setting the values for the options like this:
You can do the same thing for the other options you want to change. With this method a user could still choose to tick the boxes, but it changes the default values.
Does not seem to work for me
I must be doing something wrong, but I created the following and does not seem to work:
Not that I have both options at the same time, but I tried first with one, then with the second, and neither do anything. I've tried disabling and uninstalling the module, then installing it again.
What may I be missing? If I create content with the admin, the option appears whether I use any of the two sentences above in the function, but perhaps that is because I am the admin. But as a normal user, despite of the fact that I do not get the ability to see or alter that checkbox, the node (character) is being promoted to the front page (in both cases as well).
Also, I checked the forums module and it does not seem to have anything like that to get rid of it (I did a grep on the whole directory).
Thanks for your help.
P.S. By the way, using Drupal 6.1 here.
Hooks are implemented like
Hooks are implemented like MODULENAME_HOOKNAME(). The word 'hook' must not occur in the function's name.
Typo
My fault, sorry. I knew that, but made a typo with the copy-paste thing. Thanks for the help. Much appreciated. :)