代码之家  ›  专栏  ›  技术社区  ›  Niladri Banerjee - Uttarpara

Drupal7基于内容类型创建自定义模板不起作用

  •  1
  • Niladri Banerjee - Uttarpara  · 技术社区  · 6 年前

    我想基于“内容类型”创建一个自定义模板文件。我有一个名为(计算机名)的内容类型: oldperson_profile 我在“templates”文件夹下创建了一个文件 page--oldperson_profile.php . 现在,基于我在Google上找到的教程,我在template.php 文件:

    function mytheme_preprocess_page(&$variables, $hook) {
    
     if (isset($variables['node']->type)) {
        $variables['theme_hook_suggestions'][] = 'page__' . $variables['node']->type;
      }
    
    }
    

    https://www.digett.com/insights/overriding-page-templates-content-type-drupal-7 . 我做错什么了吗?

    1 回复  |  直到 6 年前
        1
  •  2
  •   Sanjok Gurung    6 年前

    _ 在文件名中加一个破折号“-”,同时你也不见了 tpl 所以应该是这样

    page--oldperson-profile.tpl.php