I have used this approach successfully in Drupal 6 to create a taxonomy vocabulary, select a term and then usign the following function been able to read the selection and use it in theming.
taxonomy_node_get_terms_by_vocabulary($node, $vid, $key = 'tid')
/* pull this into template.php when ready - sort taxonomy links by vocabulary 2 */
$termsfamily = taxonomy_node_get_terms_by_vocabulary(140,2);
if ($termsfamily) {
foreach ($termsfamily as $key => $termchild) {
$ltermchild = ($termchild->name);
}
}
?>
However when I write the $termsfamily array or the final value $ltermchild, I get NULL every time
This has worked ofr me so far in Drupal 4x and 5x. Does anyone see my error or know how to get this to work in Drupal 6?
Comments
I think thik that happens
I think think that could be happening, because you're not giving a proper node to te function, but a number.
perhaps it would work with:
Hello
I am using this function to filter block visibility display. I believe I am passing the $node correctly but it still does not want do the right think anybody has any suggestion?
Thank you!
I have that kind of problem
I have that kind of problem too.
I used a computed field to get the taxonomy terms associated with a node, using the following code :
$node_field[0]['value'] = print_r(taxonomy_node_get_terms_by_vocabulary($node, 4, $key = 'tid'));and it worked well, getting me an array of terms associated with the current node.
But when I load the node from the ID of a Nodereference field, I get an empty Array :
Whereas the node_load returns me the node I want.
Any idea ?