如何覆盖首页节点tpl-drupal
如何覆盖drupal front page node.tpl文件?我试过各种各样的方法如何覆盖首页节点tpl-drupal,drupal,drupal-7,Drupal,Drupal 7,如何覆盖drupal front page node.tpl文件?我试过各种各样的方法 node--front.tpl.php page--node--front.tpl.php page--front--node.tpl.php 但它不起作用 覆盖主页节点的文件名是什么?(我在drupal 7中工作)您可以将此函数添加到theme template.php中 function customethemename_preprocess_node ( &$vars
node--front.tpl.php
page--node--front.tpl.php
page--front--node.tpl.php
但它不起作用
覆盖主页节点的文件名是什么?(我在drupal 7中工作)您可以将此函数添加到theme template.php中
function customethemename_preprocess_node ( &$vars ) {
if ($vars["is_front"]) {
$vars["theme_hook_suggestions"][] = "node__front";
}
}
然后您可以翻页--front.tpl.php
它将解决这个问题我建议通过将特定的内容节点设置为首页来解决这个问题 然后我将使用一个特定的节点ID模板
node--[insert id here].tpl.php
即node--1.tpl.php
您需要做两件事,然后才能工作:
无需手动开发首页,只需按视图或其他方式创建首页,并将其设置为中的首页:
www.yoursite.com/?q=admin/config/site-information
它应该是page--front.tpl.php
另外,请确保您的主题层次结构中包含了前体(例如,
page.tpl.php
)以下步骤解决了我在Drupal 7中创建自定义首页的问题
我认为最好的解决方案是使用frontpage nid
function YOURTHEME_preprocess_node ( &$vars ) {
list(, $frontpage_nid) = explode('/', drupal_get_normal_path(variable_get('site_frontpage', 'node')));
if ($vars['node']->nid == $frontpage_nid) {
$vars['theme_hook_suggestions'][] = "node__frontpage";
}
}
因为
if ($vars["is_front"]) {
$vars["theme_hook_suggestions"][] = "node__front";
}
为frontpage中的所有节点添加主题建议,而不仅仅是frontpage节点