我遇到了一个问题,即 hook_preprocess_page 对 &$variables 的更改未呈现,即使它是 $theme_registry['page']['preprocess functions'] 下的最后一项。将 $variables 的内容记录到文件中会显示内容已更改,但站点上的内容似乎未更改。刷新了drupal上的所有缓存,刷新了所有浏览器缓存,结果仍然相同。
/**
* Implementation of hook_preprocess_page().
*/
function grinchlist_preprocess_page(&$variables) {
if (grinchlist_usercheck($variables['user']['uid'])) {
$variables['scripts'] = preg_replace('/<script[^>]*christmas_snow.*<\/script>/','',$variables['scripts']);
}
file_put_contents('/tmp/vars.txt',print_r($variables,true));
}
/tmp/vars.txt 正确显示变量,但浏览器仍显示正在加载的脚本。
这可能是一个愚蠢的例子,但我在其他情况下遇到了 hook_preprocess_page 这个问题,它真的有助于理解这里发生了什么......
谢谢。