Drupal 7 预处理函数在Drupal 7中不起作用

Drupal 7 预处理函数在Drupal 7中不起作用,drupal-7,preprocessor,theming,Drupal 7,Preprocessor,Theming,我是Drupal的新手,我正在尝试获取我们在templebartheme.info中声明的区域的描述 例:地区[faq]=常见问题 我在region.tpl.php的标准变量中没有找到这个值,所以我需要编写一个函数来完成这项工作 template.php function templebar_preprocess_region(&$vars) { $themes = list_themes(); $info = $themes['templebartheme']->

我是Drupal的新手,我正在尝试获取我们在templebartheme.info中声明的区域的描述

例:地区[faq]=常见问题

我在region.tpl.php的标准变量中没有找到这个值,所以我需要编写一个函数来完成这项工作

template.php

function templebar_preprocess_region(&$vars) {
    $themes = list_themes();
    $info = $themes['templebartheme']->info;
    $vars['region_titles'] = $info['regions'];
}
region.tpl.php

foreach ($region_titles as $name => $label) {
            if ($name == $region) {
                $region_label = $label;
            }
        }
如果我把所有的东西放在region.tpl.php上,代码就可以完美地工作,但我不想每次调用都请求所有区域的数据


为什么我的预处理功能不起作用?任何帮助都将不胜感激。

如果您的主题如信息文件所示被称为templebartheme,那么您的预处理器应该是templebartheme\u preprocess\u region。同时尝试清除缓存,这可能有助于检测新函数。感谢您的重新打印!嗯,我试着像你说的那样更改主题名称,但是没有用,所以我清理了缓存,瞧!快乐的日子!谢谢!!!