Drupal 7节点内容类型模板路径

时间:2014-06-25 18:37:44

标签: php drupal drupal-7 drupal-modules drupal-templates

我正在为Drupal 7创建一个模块。我为我的内容类型定义了一个模板作为节点 - [内容类型] .tpl.php并将其放在“themes / [selected theme] / template”目录中。我想将此模板保留在我的“模块”目录中。所以当安装模块时,我不必每次都将文件放入选定的主题文件夹。有没有办法做到这一点?

提前谢谢大家。

我的代表少于10个,所以我无法回答我自己的问题,所以我只是修改问题

以下是为我工作的一些方法。对于案例节点编辑表单视图和节点视图

function [content type]_theme() {
   return array(
    '[content type]_node_form' => array(
          'arguments' => array(
              'form' => NULL,
            ),
        'template' => 'node--[content type]--edit',
        'render element' => 'form',
        ),
    'node__[content type]' => array (
          'variables' => array(),
          'template' => 'node--[content type]' ,
          'base hook' => 'node',
          'path' => "sites/all/modules/[content type]_update/[content type]_update/[content type]/",
        ),
    );
}

我不完全理解这一点,但它正在发挥作用。

2 个答案:

答案 0 :(得分:0)

此链接可以帮助您: http://www.wdtutorials.com/2011/06/13/drupal-7-how-create-custom-theme#.U6sZ741dXag

您基本上想要创建一个新的自定义主题。 除上述教程外,还要创建一个新文件夹' templates'并在其中添加.tpl文件而不是核心主题文件夹。

答案 1 :(得分:0)

您可以使用以下格式指定模板路径。然后,您可以将tpl文件放在模块文件夹中。

function MODULENAME_theme() {
    return array(
        'yourcustom_theme' => array(
            'template' => 'mypage', // template file called mypage.tpl.php
            'path' => drupal_get_path('module', 'MODULENAME'),
        )          
    );
}
相关问题