📜 ⬆️ ⬇️

Extending hook_node_info () to customize comments, display, and other things.

I think many people face a similar problem : you create a new content type with hook_node_info() , but you still have to go into the interface and manually configure parameters such as displaying comments, publishing settings, displaying the date / author, and other things that hook_node_info() does not cover. And each time using crutches like variable_set is inconvenient.

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

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

<?php
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 be useful to many :)

')

Source: https://habr.com/ru/post/135883/


All Articles