Drupal 7:指定给定页面的标题
我有一个在 html.tpl.php 中指定的标头部分,但标头应该根据用户所在的页面而有所不同。大多数页面只是页面内容类型,尽管我稍后可能会添加其他类型以及主页。
指定要使用哪个标头然后在 home.tpl.php 中捕获该标头的最佳方法是什么?
我尝试为页面内容类型创建自定义字段,但我不知道如何从 home.tpl.php 访问它,并且我不确定如何为其他类型的页面指定它。
I have a header section that's specified in html.tpl.php, but the header should be different depending on what page the user is on. Most of the pages are just a page content type, though I might add other types later, and also the homepage.
What's the best way to specify which header to use and then catch that in home.tpl.php?
I tried creating a custom field for the page content type, but I couldn't figure out how to access it from home.tpl.php, and I'm not sure how you would specify it for other types of pages.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您的标头由
标记之间的内容组成,也许您可以在 page.tpl.php 而不是 html.tpl.php 中创建标头。这样您就可以访问
$node
变量,并能够根据字段或分类术语设置条件标头。对于更复杂的东西,您可能需要查看上下文模块: http://drupal.org/project/上下文。If your header consists of things between the
<body>
tag, perhaps you could create your header in page.tpl.php instead of html.tpl.php. This way you would have access to$node
variable and be able to set up your conditional header based on a field or taxonomy term. For something a little more complex, you might want to check out the context module: http://drupal.org/project/context.