0

我正在为 Drupal 7 开发一个模块。我为我的内容类型定义了一个模板作为 node--[content type].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]/",
        ),
    );
}

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

4

2 回答 2

0

这个链接应该让你去: http ://www.wdtutorials.com/2011/06/13/drupal-7-how-create-custom-theme#.U6sZ741dXag

您基本上想创建一个新的自定义主题。除了上述教程之外,创建一个新文件夹“模板”并在其中添加您的 .tpl 文件,而不是核心主题文件夹。

于 2014-06-25T18:47:50.000 回答
0

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

function MODULENAME_theme() {
    return array(
        'yourcustom_theme' => array(
            'template' => 'mypage', // template file called mypage.tpl.php
            'path' => drupal_get_path('module', 'MODULENAME'),
        )          
    );
}
于 2014-06-27T06:09:57.040 回答