Я так понял что автор хочет отображать блок не на страницах термина таксономии, где задача легко решается с помощью pathauto, а именно в зависимости от того, к какому термину принадлежит нода, выводить блок.
Например если нам надо выводить блок на страницах с нодами с термином таксономиии с ID 1 php-код для показа блока на нужных нодах - внизу, в настройках блока.
<?php
// Vocabulary term ID for which to display the block: $displayTermID =1;
// This will show on the index page for that term if ((arg(0) == 'taxonomy') && (arg(1) == 'term') && (arg(2) == $displayTermID)) { return TRUE; }
// Get all taxonomy terms for current node: $currNodeTerms = taxonomy_node_get_terms(node_load(arg(1)));
// If there are no terms, fail-fast:
if (is_null($currNodeTerms) || 0 == count($currNodeTerms)) { return FALSE; }
// For each term of the current node, get all the ancestor terms: foreach($currNodeTerms as $term) {
// Check for each ancestor term whether it is the term we are looking for. // If it is, return TRUE immediately: if (!is_null($ancestors) && 0 < count($ancestors)) { foreach($ancestors as $ancestor) { if ($displayTermID == $ancestor->tid) { return TRUE; } } } }
// If we didn't find our term of interest, return FALSE: return FALSE; ?>
Комментарии
писать php-код для показа блока на нужных нодах - внизу, в настройках блока.
if ( (arg(0) == 'taxonomy') && (arg(1) == 'term') && (arg(2) == 1) ) {
return true
}
else {
return false;
}
?>
arg(2) == 1 - замените 1 ID нужного термина таксономии
ИЛИ
"Показывать только на перечисленных страницах", введите строку
taxonomy/term/1
и замените 1 ID нужного термина
Я так понял что автор хочет отображать блок не на страницах термина таксономии, где задача легко решается с помощью pathauto, а именно в зависимости от того, к какому термину принадлежит нода, выводить блок.
Например если нам надо выводить блок на страницах с нодами с термином таксономиии с ID 1
php-код для показа блока на нужных нодах - внизу, в настройках блока.
<?php // Vocabulary term ID for which to display the block:
$ancestors = taxonomy_get_parents_all($term->tid);
$displayTermID =1; // This will show on the index page for that term
if ((arg(0) == 'taxonomy') && (arg(1) == 'term') && (arg(2) == $displayTermID)) {
return TRUE;
} // Get all taxonomy terms for current node:
$currNodeTerms = taxonomy_node_get_terms(node_load(arg(1))); // If there are no terms, fail-fast: if (is_null($currNodeTerms) || 0 == count($currNodeTerms)) {
return FALSE;
} // For each term of the current node, get all the ancestor terms:
foreach($currNodeTerms as $term) {
// Check for each ancestor term whether it is the term we are looking for.
// If it is, return TRUE immediately:
if (!is_null($ancestors) && 0 < count($ancestors)) {
foreach($ancestors as $ancestor) {
if ($displayTermID == $ancestor->tid) {
return TRUE;
}
}
}
} // If we didn't find our term of interest, return FALSE:
return FALSE;
?>
Для семерки такой код никто не пробовал прописать?