Drupal:如何为模块设置主题 [英] Drupal: How to theme a module
问题描述
我正在尝试为模块输出设置主题.特别是我正在研究 http://drupal.org/project/service_links
I'm trying to theme a modules output. In particular i'm working on http://drupal.org/project/service_links
知道它是如何工作的吗?
Any idea how that works?
提前致谢!
推荐答案
通常,如果您想为模块设置主题,您有几个选择.
Generally, if you want to theme a module you have a few options.
覆盖主题功能.您可以覆盖模块使用/实现的主题函数来更改标记,此类函数的一个示例是
theme_service_links_node_format
.您在主题的 template.php 中更改了一个名为your_theme_name_service_links_node_format"的函数,并在其中创建自定义标记.
Overwrite theme functions. You can overwrite the theme functions that the module uses/implements to change the markup, one example of such a function is
theme_service_links_node_format
. You change make a function in your theme's template.php called 'your_theme_name_service_links_node_format' and make your custom markup in it instead.
CSS.如果您不需要更改模块输出的实际标记,您只需要添加所需的 css,以根据您的喜好将其主题化.
CSS. If you don't need to change the actual markup of a modules output, you only need to add the needed css, to theme it into your liking.
在某些情况下,看起来服务链接不是这样的,您也可以制作自己的模板,并让 Drupal 使用它们.
In some cases, it doesn't look like sercive links is such a case, you can also make your own templates, and make Drupal use them instead.
另一种方式,再次看起来不像服务是服务链接是这种情况,是在你的template.php 中实现预处理功能.如果您想更改某些模板变量的生成方式,则需要这样做.
Another way, again it doesn't look like service is service links is such a case, is to implement preprocess functions in your template.php. This is needed if you want to alter how certain template variables are generated.
这篇关于Drupal:如何为模块设置主题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!