Drupal 6 Drupal 6-节点项的父项id

Drupal 6 Drupal 6-节点项的父项id,drupal-6,Drupal 6,我一直在努力将节点术语的父术语id放入views参数中。让我解释一下为什么我要做这么奇怪的事。在术语页面上,我展示了一个包含该术语下所有节点列表的块。但单击任何节点时,该块就会消失,因为视图中的默认参数(用于术语id)为: if(arg(0)=‘分类法’&&arg(2)!=“”){ 返回arg(2); } 这是为了分类安排,如团队>>国家>>澳大利亚>>功能、文章等。 这里:词汇是团队:国家是主要术语,澳大利亚是儿童术语和特写,文章等是儿童术语 没关系。但由于我也想在该术语的节点页面上显示该块,

我一直在努力将节点术语的父术语id放入views参数中。让我解释一下为什么我要做这么奇怪的事。在术语页面上,我展示了一个包含该术语下所有节点列表的块。但单击任何节点时,该块就会消失,因为视图中的默认参数(用于术语id)为: if(arg(0)=‘分类法’&&arg(2)!=“”){ 返回arg(2); } 这是为了分类安排,如团队>>国家>>澳大利亚>>功能、文章等。 这里:词汇是团队:国家是主要术语,澳大利亚是儿童术语和特写,文章等是儿童术语 没关系。但由于我也想在该术语的节点页面上显示该块,我想提取该节点术语的父术语“ID”[因为(比如)节点是Feature下的一篇文章,而我正在显示的节点列表块是Australia术语下的。]这样我就可以添加进一步的参数,如: elseif(arg(0)=“节点”){ 然后。。。。。。
Plz帮助。

如果我正确理解了问题,您希望显示一个块,其中显示具有与节点术语的直接父项相同的分类术语的所有节点。 如果节点有两个术语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));
}
在某种程度上,上面的解决方案与术语参数的深度属性和深度修饰符类似