How to change default properties on custom drupal type nodes ?

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:

  • 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 ?

  • 0 – Disabled
  • 1 – Enabled

Do you want the page to be promoted on front page by default ?

  • ‘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


2 Thoughts on “How to change default properties on custom drupal type nodes ?

  1. 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.

    • Admin on October 2, 2013 at 15:04 said:

      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

Leave a Reply

Your email address will not be published. Required fields are marked *

Post Navigation