I should put this in its own issue queue. Will this pull the top level taxonomy term id? context_set('node', 'tid', $node->taxonomy[0]);

Comments

brynbellomy’s picture

Status: Active » Fixed

I believe that the taxonomy array on a $node object is keyed by tid, so you'd probably have to do something like:

$terms = array_values($node->taxonomy);
context_set('node', 'tid', $terms[0]);

or perhaps

$first = reset($node->taxonomy);
context_set('node', 'tid', $first);

... this is assuming that taxonomy builds the array so that lowest weighted terms (and highest terms in the tree) are at the front of the array. In any case, tell me if you have any luck with this.

Adam S’s picture

Thank you.

brynbellomy’s picture

Oh, you know what? I forgot -- you can't context_set an object. Serialize the objects and you're fine, though. Change the above code to:

$terms = array_values($node->taxonomy);
context_set('node', 'tid', serialize($terms[0]));

and

$first = reset($node->taxonomy);
context_set('node', 'tid', serialize($first));

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

hixster’s picture

subscribing