Php Drupal 7节点内容类型模板路径
我正在为Drupal7开发一个模块。我将我的内容类型的模板定义为node--[content type].tpl.php,并将其放置在“themes/[selected theme]/template”目录中。我想将此模板保留在我的“模块”目录中。因此,在安装模块时,我不必每次都将文件放入选定的主题文件夹中。有办法做到这一点吗 提前谢谢大家 我只有不到10个代表,所以我不能回答我自己的问题,所以我将修改问题 下面是一些如何为我工作。对于案例节点编辑表单视图和节点视图Php Drupal 7节点内容类型模板路径,php,drupal,drupal-7,drupal-modules,drupal-templates,Php,Drupal,Drupal 7,Drupal Modules,Drupal Templates,我正在为Drupal7开发一个模块。我将我的内容类型的模板定义为node--[content type].tpl.php,并将其放置在“themes/[selected theme]/template”目录中。我想将此模板保留在我的“模块”目录中。因此,在安装模块时,我不必每次都将文件放入选定的主题文件夹中。有办法做到这一点吗 提前谢谢大家 我只有不到10个代表,所以我不能回答我自己的问题,所以我将修改问题 下面是一些如何为我工作。对于案例节点编辑表单视图和节点视图 function [cont
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]/",
),
);
}
我不完全理解这一点,但它正在发挥作用。此链接应该可以帮助您: 您基本上希望创建一个新的自定义主题。
除了上面的教程之外,创建一个新文件夹“templates”,并在其中添加.tpl文件,而不是核心主题文件夹。您可以使用以下格式指定模板路径。然后,您可以将tpl文件放在模块文件夹中
function MODULENAME_theme() {
return array(
'yourcustom_theme' => array(
'template' => 'mypage', // template file called mypage.tpl.php
'path' => drupal_get_path('module', 'MODULENAME'),
)
);
}
实际上,在我之前有人做过这个模块。他创建了一个模板节点--[content-type]--edit.tpl.php,该节点附加到[content-type]的编辑表单。我找到了一个this code
函数[content type]\u theme(){return array('[content type]\u node\u form'=>array('arguments'=>array('form'=>NULL,),'template'=>'节点--[content type]--edit','render element'=>'form',);}
我不知道如何对我的节点[内容类型]视图执行类似操作您需要将path元素添加到数组中。这可能有助于: