如何使用drupal template.php进行基于分类的css样式化?
我期待着实现基于分类术语的css样式;特别是对于body标签,我想添加当前的术语 现在,以下是我目前的情况:如何使用drupal template.php进行基于分类的css样式化?,css,drupal,taxonomy,Css,Drupal,Taxonomy,我期待着实现基于分类术语的css样式;特别是对于body标签,我想添加当前的术语 现在,以下是我目前的情况: function _phptemplate_variables($hook, $vars = array()) { global $node; switch ($hook) { case 'page': die ('test'); $vars['body_class'] = ''; if
function _phptemplate_variables($hook, $vars = array()) {
global $node;
switch ($hook) {
case 'page': die ('test');
$vars['body_class'] = '';
if (arg(0) == 'taxonomy' && arg(1) == 'term' && is_numeric(arg(2))) {
$vars['body_class'] = 'theme'.arg(2);
}
if (arg(0) == 'node' && is_numeric(arg(1))) {
$node = node_load(arg(1));
if (is_array($node->taxonomy)) {
foreach ($node->taxonomy as $term) {
$vars['body_class'] .= 'theme'.$term->tid;
}
}
}
if (drupal_is_front_page()) {
$vars['body_class'] .= ' front';
}
break;
}
return $vars;
}
我认为代码还可以,但从未被调用过(参见我的'die'函数);使用简单的phptemplate引擎和最少的drupal6安装
我在这里错过了什么明显的东西?好吧,几年前我们写了这个
/**
* Override or insert PHPTemplate variables into the templates.
*/
function phptemplate_preprocess_page(&$vars) {
//
}
/**
* Override or insert PHPTemplate variables into the templates.
*/
function phptemplate_preprocess_node(&$vars) {
//
}
我希望Drupal 6或7需要更新它,但原则仍然适用。对于Drupal 7,更优雅的解决方案可能是使用。有关详细信息和说明,请参阅以下帖子
上下文模块允许为特定Drupal页面创建任意上下文,例如基于分类术语。这些上下文可能会触发某些反应,例如,添加带有所选分类术语的CSS类。函数_phptemplate_variables($hook,$vars){die('here');}也不会执行。因此,现在我知道这不是问题所在!但我不得不问:-)这个脚本执行过吗?如果您放置
die('here')代码>在任何功能之外它会消亡吗?单链接答案不是最好的。请用几句话描述URL末尾的内容