When creating a node type programatically, some node type options can be set in hook_node_info
, including name
, base
, description
, has_title
, title_label
, has_body
, and help
. As far as these node options go, using hook_node_info
is cleary the canonical way of doing it.
However, some additional node type options cannot be set using this hook, and I have not yet found any canonical documentation that explains how do do this.
The options I look for a method of setting programatically include:
- whether commenting by default are open or closed;
- whether the node should be published, promoted, sticky and/or have revisions enabled upon creation;
- whether it should display author and date information.
The solution I currently use is to set the appropriate database variables in hook_install
for the module that creates my_nodetype
to the defaults I want, e.g.:
variable_set('comment_my_nodetype', COMMENT_NODE_CLOSED);
variable_set('node_options_my_nodetype', array('status','promote'));
variable_set('node_submitted_my_nodetype', FALSE);
I figured out this solution by reading the source code to discover that these database variables determine behavior at runtime. I've not found documented anywhere how one should go about setting these additional node type options.
Is there a better way of doing this than the improvised soluton I currently use?