【问题标题】:page-front.tpl.php not workingpage-front.tpl.php 不工作
【发布时间】:2011-10-27 16:08:43
【问题描述】:

我正在为 drupal 7 站点的首页设置模板,但遇到了困难。我将文件保存在正确的文件夹中,清除了所有缓存,并刷新了主题页面和浏览器页面。有什么我想念的吗?为什么这不起作用?

【问题讨论】:

  • “不工作”是什么意思? Drupal 中的错误或只是一个空白页?
  • 添加的样式只是没有显示,所以它仍然显示原始 page.tpl 而不是 page-front.tpl 应该是 page--front.tpl

标签: drupal drupal-7


【解决方案1】:

在 Drupal 7 中,我相信您需要 page--front.tpl.php -- 注意两个破折号。

【讨论】:

    【解决方案2】:

    theme_get_suggestions(),从template_preprocess_page()调用为theme_get_suggestions(arg(), 'page'),包含以下代码:

    if (drupal_is_front_page()) {
      // Front templates should be based on root only, not prefixed arguments.
      $suggestions[] = $base . $delimiter . 'front';
    }
    

    $base 包含 "page"$delimiters 包含 "__"。由于下划线替换为连字符,因此首页的模板文件名必须是 page--front.tpl.php(两个连字符而不是一个连字符)。

    【讨论】:

      猜你喜欢
      • 2017-08-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多