【问题标题】:Convert drupal 7 content type into code automatically. Content type generator code?自动将 drupal 7 内容类型转换为代码。内容类型生成器代码?
【发布时间】: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


    【解决方案1】:

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

    检查this documentation link

    【讨论】:

    • 非常感谢,这正是我需要的:)
    【解决方案2】:

    也许这对你有帮助。

    添加 hook_install():

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

    【讨论】:

    • 我已经看过这个链接,这与我想要做的无关。我想要一些东西来自动生成内容类型的代码。谢谢。
    猜你喜欢
    • 2013-09-05
    • 1970-01-01
    • 1970-01-01
    • 2015-07-01
    • 1970-01-01
    • 2011-10-11
    • 2017-11-28
    • 2012-07-14
    • 1970-01-01
    相关资源
    最近更新 更多