Ok I have a 2 tier taxonomy e.g:

- Business
- Politics
- Responsible Investing
- Living
- Home & Garden
- Art & Design

And nodes can be tagged by any combination of children.

In a view, I want to list All Parent Terms in a single row, for instance if a Node has the following Child Terms:

- Politics
- Responsible Investing
- Home & Garden
- Art & Design

Then the output I would desire is: "Business, Living"

I can't figure out a way to do this without merging about 2-3 separate views together (in my head). I don't want to go to that extent as I'm wondering if there's a better or "correct" way to do it?

Thanks for any advice :)

Comments

iamjon’s picture

Status: Active » Postponed (maintainer needs more info)

carn1x,
can you provide step by step instructions of what you're trying to achieve, i don't really understand the question.

carn1x’s picture

Status: Postponed (maintainer needs more info) » Fixed

Oh I ended up solving this with a custom module, sorry should have closed it.

I just re-read my post and realized the formatting was lost which probably didn't help any lack of replies for over a month!

Never mind, thanks for the interest to help!

carn1x’s picture

Status: Fixed » Closed (fixed)
iamjon’s picture

carn1x,
Thanks for the update, if possible can you post your solution so others can benefit.

carn1x’s picture

I just made a custom module which provides a function which I'm using at the theme level to take the nid and then output the term parents of a hardcoded taxonomy ID. My code is not reusable unless you're prepared to modify it, but here it is:

In the theme ($output is the nid supplied by a view field):

$sectionArray=_taxonomy_get_sections($output);
$sectionLinks=array();
foreach($sectionArray as $tid => $section){
  $sectionLinks[]=l($section,"taxonomy/term/$tid");
}
print implode(', ',$sectionLinks);

In the custom module:

function _taxonomy_get_sections($nid){
$sectionArray=array();
  if(is_numeric($nid)){
    $sql="
      SELECT DISTINCT
        td_sec.name,
        td_sec.tid
      FROM term_data td_cat
      JOIN term_node tn_cat
        ON td_cat.tid=tn_cat.tid
      JOIN term_hierarchy th_cat
        ON tn_cat.tid=th_cat.tid
      JOIN term_data td_sec                                                                                                                        
        ON th_cat.parent=td_sec.tid
      WHERE
        nid=$nid
        AND td_cat.vid=1
    ";
    if($query=db_query($sql)){
      while($result=db_fetch_object($query)){
        $sectionArray[$result->tid]=$result->name;
      }
    }
  }
  return $sectionArray;
}