搞清楚在html.tpl.php父链接 [英] Figuring out the parent link in html.tpl.php

查看:137
本文介绍了搞清楚在html.tpl.php父链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法找出父页面的标题是html.tpl.php?我这么问是因为我取决于被选我的网页上什么父链接改变我的背景图片。
希望这是有道理的,网址是: http://quaaoutlodge.com/drupal-7.14/

Is there a way to figure out what the title of the parent page is in html.tpl.php? I'm asking because I change my background image depending on what parent link was chosen on my page. Hope it makes sense, the url is: http://quaaoutlodge.com/drupal-7.14/

谢谢,
罗恩

没弄清楚如何可以做到这一点......不得不修改我的建筑,并采取必要的步骤来完成我想做的事...

Didn't figure out how this can be done... had to revise my architecture and take the required steps to accomplish what I wanted to do...

推荐答案

PHP是一种服务器端编程语言。当用户请求一个页面时,服务器该网页执行PHP和生成的HTML发送给用户。 PHP通信只发生在这种方式。用户只会看到生成的HTML。如果用户需要用PHP交互(例如,更改的页面输出),用户必须启动另一个寻呼请求

PHP is a server-side programming language. When a user requests a page, the server executes the PHP for that page and sends the resulting HTML to the user. PHP communication only happens in this way. The user only ever sees the resulting HTML. If the user needs to interact with PHP (like changing the page output), the user has to initiate another page request.

JavaScript是一种客户端编程语言。在正常服务器环境中,使用Javascript执行只发生在用户的机器上(服务器不)。 JavaScript执行PHP执行过程中不会发生,所以你不能用PHP code混合的Javascript code。拉布的使用JavaScript建议,不回答你的问题,你的给他的答复是企图的Javascript PHP混合。

Javascript is a client-side programming language. In a normal server environment, Javascript execution only occurs on the user's machine (not on the server). Javascript execution does not occur during PHP execution, so you can't mix Javascript code in with PHP code. Rab's suggestion to use Javascript doesn't answer your question, and your reply to him was attempting to mix Javascript with PHP.

在Drupal的方面,你有你的网站通过有组织的菜单访问节点的集合。你想在页面上更改特定图像(我要去承担Quaaout洛奇标志)每当用户查看特定的第一级菜单项的子页面。例如,观看我们的历史或前往此处将装载(而不是默认的Quaaout洛奇标志)以某种方式连接到洛奇的父项不同的图像

In Drupal terms, you have a collection of nodes on your site accessed through an organized menu. You want to change a specific image on the page (I'm going to assume the Quaaout Lodge logo) whenever the user is viewing a child page of a specific first-level menu item. E.g., viewing "Our History" or "Getting Here" would load (instead of the default Quaaout Lodge logo) a different image connected in some way to the parent item of "The Lodge".

一个最简单的解决方案,因为它好像你是不是很熟悉的Drupal将指定图像作为一个CSS 背景图片属性,而不是作为一个 IMG 元素。每个页面都应该有应用于的页面元素的唯一的类属性。例如,在我们的历史页面上,应用于体中的一个类元素是页节点-7 页节点-7 不应用于在Drupal任何其他页面。您可以快速查找每个页面的唯一的类,并添加CSS属性更改背景图片为每一个等,如果你想用这个方法,但使它有点清洁剂,您可能能够通过使用节点类模块应用自定义类,每一页来改善它。你可以添加一个小屋图像类,你的洛奇菜单项下创建的每个页面。这将让内容编辑更改特定页面的图像,而不需要任何人直接修改CSS。我假设(我可能是错的),在Drupal7节点类模块将一个类添加到body元素以及节点的HTML容器中。

One of the easiest solutions since it seems like you aren't very familiar with Drupal would be to specify the image as a background-image property in CSS instead of as an img element. Each page should have a unique class attribute applied to the body element of its page. E.g., on the "Our History" page, one of the classes applied to the body element is page-node-7. page-node-7 is not applied to any other page in Drupal. You can quickly look up each page's unique class and add CSS properties to change the background-image for each one, etc. If you want to use this method but make it a bit cleaner, you might be able to improve it by using the Node Class module to apply custom classes to each page. You could add a "lodge-image" class to each page that you create under the "The Lodge" menu item. This would let content editors change the image for specific pages without anyone needing to directly modify the CSS. I'm assuming (I might be wrong) that the Node Class module in Drupal7 would add a class to the body element as well as the node's HTML container.

可替换地,一个更好的解决方案将是使用一个Drupal模块基于某些菜单或路径条件来选择标志。如果图像是使用在Drupal标志配置选项(在外观设置)设置这些只会工作。最合适的模块很可能会徽标工具,但尚未对Drupal7开发的,所以它不是又一个选项。该子网站模块在发展Drupal7版本。开发版本通常不建议在生产场地使用,但似乎这是值得一试。

Alternatively, a better solution would be to use a Drupal module to select the logo based on certain menu or path conditions. These will only work if the image is set using the logo configuration options in Drupal (in the Appearance settings). The most appropriate module would probably be Logo Tool, but it has not yet been developed for Drupal7, so it's not yet an option. The Subsites module has a Drupal7 release in development. Dev releases aren't typically recommended for use on production sites, but it seems like it's worth a shot.

一些其他的方法,这将是的更好的,但会比较困难有:覆盖/设置一个的template.php preprocess功能标识,写一个新的模块要么设置标志或创建自定义图像块(并添加一个新的区域,以你的主题,其中显示该块),转换徽标工具Drupal7自己,写一个新的模块,自动将类属性添加到该网页的菜单祖先body元素(CSS方法没有必要超越创建菜单项的附加动作),还增加了一些我能想到的。

Some other methods that would be better but would be more difficult are: override/set the logo in a template.php preprocess function, write a new module to either set the logo or create a custom image block (and add a new region to your theme in which to display the block), convert Logo Tool to Drupal7 yourself, write a new module to automatically add a class attribute to the body element for the page's menu ancestors (CSS method without additional action needed beyond creating the menu entry), and a few more I can think of.

所以,你有很多的选择。

So you have a lot of options.

这篇关于搞清楚在html.tpl.php父链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆