将drupal7内容类型自动转换为代码.内容类型生成器代码


Convert drupal 7 content type into code automatically. Content type generator code?

我的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);

非常感谢。

也许您应该看看Features模块。使用功能可以将您的内容类型和添加的字段导出到模块中,以后可以安装到另一个网站。

请检查此文档链接。

也许这可以帮助您。

add hook_install():

请检查:http://yaremchuk.ru/blog/how-create-content-type-drupal-7-programmatically