Если я правильно понимаю вопрос, вы хотите отобразить блок, в котором показаны все узлы с таким же термином таксономии, что и непосредственный родительский термин термина.В случае, если у узла есть 2 слагаемых a> b (то есть a является родителем b), тогда этот термин является a.Если у вас есть a> b> c и все они установлены, то у вас есть a и b в качестве некоторых терминов «родители».Тогда блок должен будет показать все узлы, которые имеют a и b как термины.
, поэтому продолжение будет:
else if (arg(0) == 'node' && is_numeric(arg(1)))) {
$n = node_load(arg(1));
$vid = 0; // change for the required vocabulary
$tids = array(); // will hold all the parents of the node's terms
foreach ($n->taxonomy as $tid => $term) {
if ($term->vid == $vid) {
$parents = taxonomy_get_parents($term->tid);
// the term has a parent
if (count($parents)) {
$parent = array_shift($parents);
$tids[] = $parent->tid;
// if you require only one parent term, return the first one that we find
// comment the next line if you want all terms that act as parents
return $parent->tid;
}
}
}
// in this case, make sure that you
// check the 'Allow multiple terms per argument' checkbox
// and argument type is 'Term IDs separated by , or +'
return implode(',', array_unique($tids));
}
В некотором смысле, решение выше работает как атрибут глубиныи модификатор глубины для аргумента термина.