gpt4 book ai didi

drupal - 在 html.tpl.php 中获取 $node 变量 - Drupal 7

转载 作者:行者123 更新时间:2023-12-04 06:26:04 24 4
gpt4 key购买 nike

我试图让用户更新每个页面的标题和元描述。我认为实现此目的的一种简单方法是在页面标题的“基本页面”内容类型中添加一个字段,然后检查该字段在 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
}
}

关于drupal - 在 html.tpl.php 中获取 $node 变量 - Drupal 7,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6956870/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com