I just want to print my region in de page.tpl.php only if the current page is a taxonomy page. So I need something like a check if the current page is the frontpage, but then a check for taxonomy
我只想在de page.tpl.php中打印我的区域,前提是当前页面是分类页面。所以我需要检查当前页面是否为首页,然后检查分类
<?php
if(currentpage == taxonomy){
print render($page['sidebar'])
}
?>
Thanks for your help,
谢谢你的帮助,
2 个解决方案
#1
3
You can use the arg()
function to get the underlying parts of the current page path (i.e. not the URL alias). In your case it would be like this:
您可以使用arg()函数获取当前页面路径的底层部分(即不是URL别名)。在你的情况下,它将是这样的:
if (arg(0) == 'taxonomy' && arg(1) == 'term') {
print render($page['sidebar']);
}
#2
0
if you have more than one vocabulary, you can integrate Clive suggestion that way:
如果您有多个词汇表,可以通过以下方式集成Clive建议:
if (arg(0) == 'taxonomy' && arg(1) == 'term' && is_numeric(arg(2)))
{
$tid = (int)arg(2);
$term = taxonomy_term_load($tid);
if($term->vocabulary_machine_name == '<YOUR_VOCABULARY_MACHINE_NAME>') print render($page['sidebar']);
}
#1
3
You can use the arg()
function to get the underlying parts of the current page path (i.e. not the URL alias). In your case it would be like this:
您可以使用arg()函数获取当前页面路径的底层部分(即不是URL别名)。在你的情况下,它将是这样的:
if (arg(0) == 'taxonomy' && arg(1) == 'term') {
print render($page['sidebar']);
}
#2
0
if you have more than one vocabulary, you can integrate Clive suggestion that way:
如果您有多个词汇表,可以通过以下方式集成Clive建议:
if (arg(0) == 'taxonomy' && arg(1) == 'term' && is_numeric(arg(2)))
{
$tid = (int)arg(2);
$term = taxonomy_term_load($tid);
if($term->vocabulary_machine_name == '<YOUR_VOCABULARY_MACHINE_NAME>') print render($page['sidebar']);
}