【发布时间】:2015-09-14 05:16:19
【问题描述】:
将以下代码应用到template.php后,自定义节点模板在Drupal 7上不起作用。例如,node--article.tpl.php
function jstheme_preprocess_page(&$variables) {
if (isset($variables['node']->type)) {
// If the content type's machine name is "my_machine_name" the file
// name will be "page--my-machine-name.tpl.php".
$variables['theme_hook_suggestions'][] = 'page__' . $variables['node']->type;
}
}
如果我删除上面的代码,节点--article.tpl.php 正在拾取但不是页面--article.tpl.php
我假设它应该选择页面--article.tpl.php 然后节点--article.tpl.php(如果存在)。这个假设是错误的吗?
【问题讨论】: