If you want to set some default properties on your freshly created custom node type on Drupal, you have to use variable_set syntax like this:
In your <my_custom_module_name>.install file, add these lines according to what you need to set.
If you want a language to be set by default, use this:
1 |
variable_set('language_content_type_<my_custom_module_name>',0); |
- 0 – Disabled
- 1 – Enabled
- 2 – Enabled with translation (core’s translation.module – TRANSLATION_ENABLED)
- 4 – Enabled, with field translation (entity_translation.module – ENTITY_TRANSLATION_ENABLED)
Do you want to enable or disable comments by defaults ?
1 |
variable_set('comment_<my_custom_module_name>', 1); |
- 0 – Disabled
- 1 – Enabled
Do you want the page to be promoted on front page by default ?
1 |
variable_set('node_options_<my_custom_module_name>', array('status')); |
- ‘status’ => t(‘Published’),
- ‘moderate’ => t(‘In moderation queue’),
- ‘promote’ => t(‘Promoted to front page’),
- ‘sticky’ => t(‘Sticky at top of lists’),
- ‘revision’ => t(‘Create new revision’),
Disable author and date by default
1 |
variable_set('node_submitted_<my_custom_module_name>', 0); |
This is awesome– is this documented anywhere else? I’m trying to programmatically create a Drupal node type and set things like Display defaults for its fields, widget types and settings, etc., and I can’t find an all-inclusive resource with all the different options and key names.
Where did you find your information? Just digging around core files? Thanks.
Yes, I read it directly from the drupal core. I thought it would be useful to someone else too. It was such a pain in the ass to find everything I wanted :d