Extending hook_node_info () to configure comments, display and other things

    I think many people face a similar problem : you create using a hook_node_info()new type of content, but you still have to go into the interface and manually configure parameters such as the display of comments, publication settings, date / author display and other things that are hook_node_info()not covered. And every time using crutches of type variable_set is inconvenient.

    My patience did burst, and a couple of hours were spent for the benefit of humanity: the result was a small module nodetools .

    All that he does is allows hook_node_info to specify additional properties of the generated content type.
    Its use is as follows ( in detail with comments ):

    function hook_node_info() {
      return array(
        'customtype' => array(
          'name' => t('Custom node type'),
          'base' => 'custom',
          ...
          // Extra properties
          'node-preview' => 0,
          'node-options' => array('status', 'promote', 'sticky', 'revision'),
          'node-submitted' => 0,
          'comment' => array(
            'status' => 2,
            'default-mode' => 1,
            'anonymous' => 1,
            'default-per-page' => 50,
            'form-location' => 1,
            'preview' => 0,
            'subject-field' => 0,
          ),
        ),
      );
    }
    * This source code was highlighted with Source Code Highlighter.

    I am sure it will come in handy for many :)

    Also popular now: