【发布时间】:2013-09-05 01:46:57
【问题描述】:
我的 drupal 项目中已经有一个内容类型。
我目前正在开发自己的模块,并希望创建一个内置的内容类型。 有没有办法将我直接在 drupal 中构建的内容类型转换为代码? 一种内容类型代码生成器?。
如果可能,我想自动生成此代码。
$t = get_t();
// Define the node type.
$slider = array(
'type' => 'slider',
'name' => $t('Slider Content'),
'base' => 'node_content',
'description' => $t('This is an example node type with a few fields.'),
'body_label' => $t('Example Description')
);
// Complete the node type definition by setting any defaults not explicitly
// declared above.
// http://api.drupal.org/api/function/node_type_set_defaults/7
$content_type = node_type_set_defaults($slider);
node_add_body_field($content_type);
// Save the content type
node_type_save($content_type);
非常感谢。
【问题讨论】:
标签: php drupal drupal-7 drupal-modules drupal-content-types