【发布时间】:2009-10-08 06:09:39
【问题描述】:
【问题讨论】:
【问题讨论】:
您可以很容易地在您的主题中做到这一点,有不同的方法可以做到。最简单的可能是在你的 template.php 中完成
/* this function generates the variables that are available in your node.tpl,
* you should already have this in your template.php, but if not create it
*/
function mytheme_preprocess_node(&$vars) {
// It's important to run some kind of filter on the title so users can't
// use fx script tags to inject js or do nasty things.
$vars['title'] = filter_xss($vars['node']->title);
}
函数中发生的事情是它覆盖了 node.tpl 中 $title 的默认值,其中包含用于标题的变量。它通常放置在 h1 或 h2 标记中,因此您应该注意这一点。 filter_xss用来只允许基本的html标签,所以保护网站,你可以看看那个函数here。那是其他一些过滤器功能,例如 check_markup 和 filter_xss_admin,但您可以为 filter_xss 提供第二个参数,这是一个允许的标签数组,因此如果默认值不够好,您可以更改它以满足您的需要。
【讨论】:
对D7 使用函数mytheme_preprocess_page。
【讨论】:
扩展wiifm提到的模块,对于D7,现在还有:https://drupal.org/project/html_title_trash
它允许更多标签,也适用于块标题,而不仅仅是节点标题。
【讨论】: