我正在尝试允许用户更新每个页面的标题和元描述.我认为实现这一目标的一种简单方法是在页面标题的"基本页面"内容类型中添加一个字段,然后在html.tpl.php中检查该字段是否为空,如果不是,则覆盖$ head_title具有此用户定义的值.
但是,似乎$ node变量在html.tpl.php中不可用.有人可以建议我在这个模板文件中提供这些数据的方法,或者在发送到html.tpl.php之前改变$ head_title吗?谢谢阅读.
部分来自我发现的这个帖子:http://drupal.org/node/1041768 ...
在您的中template.php,您可以执行以下操作:
function yourtheme_preprocess_html(&$variables) {
// If on an individual node page, add the node type to body classes.
if ($node = menu_get_object()) {
$variables['head_title'] = $node-> // find your cck field here
}
}
Run Code Online (Sandbox Code Playgroud)