Программно создать свой тип материала
14 января 2017
Пример программного создания типа материала news:
// Создаём content type
$news_node_type = node_type_set_defaults(array(
'type' => 'news',
'name' => 'News',
'base' => 'node_content',
'description' => 'Description...',
'custom' => 1,
'modified' => 1,
'locked' => 0,
'title_label' => 'News title',
));
node_type_save($news_node_type);
// Добавляем поле body
node_add_body_field($news_node_type, 'News text');
// Изменяем "Publishing options"
variable_set('node_options_news', array('status'));
// Изменяем "Menu settings"
variable_set('menu_options_news', array());
// Изменяем "Comment settings"
variable_set('comment_news', COMMENT_NODE_HIDDEN);