[英]Drupal 7 Node Content Type Template Path
我正在为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]/",
),
);
}
我不完全了解这一点,但它正在起作用。
该链接应该可以帮助您: http : //www.wdtutorials.com/2011/06/13/drupal-7-how-create-custom-theme#.U6sZ741dXag
您基本上想创建一个新的自定义主题。 除了上述教程之外,还创建一个新文件夹'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'),
)
);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.