Posted by arcX on January 16, 2006 at 11:38am
Hi Drupal developers,
I know that there is a term associated with my node, as I have checked in the DB.
But when I do this (In a flexinode .tpl file or even using template.php) I get an empty Array.
<?php
$terms = taxonomy_node_get_terms($node->nid)
print $terms[0];
?>Well, I do not see a relevant error in the PHP logs, or in the Apache logs, so I do not know how to test if the fuction call has worked.
Please help me to understand how to debug this one?
Alex.
Comments
Yeah, I think it can help
Yeah, I think it can help you:
<?phpunset($terms);
$terms = taxonomy_node_get_terms($node->nid);
print_r($terms); //You can see the array before use rsort()
echo '<br />';
rsort($terms);
print $terms[0]->name;
echo '<br />';
print_r($terms); //You can see the array after use rsort()
?>
You can use print_r to help you debug arrays.
My Blog: http://fred.oracle1.com/
My Site: http://www.skapal.com/
I am having a similar
I am having a similar problem, the node has terms but:
unset($terms);
$terms = taxonomy_node_get_terms($node->nid);
print_r ($terms);
returns only:
Array ( )
the code is on a flexinode phpTemplate page.
------------------------------------------------------
Jump through a few hoops, get a free iPod.
http://ipods.freepay.com/?r=8480908
-----------------------------------------------------
www.fulleffectmagazine.com
Jump through a few hoops, get a free iPod.
http://ipods.freepay.com/?r=8480908
Drupal 6
If you use Drupal 6 try this:
$terms = taxonomy_node_get_terms($node);
instead of this:
$terms = taxonomy_node_get_terms($node->nid);
To get node TID in D6
To get node TID:
<?php
$terms = taxonomy_node_get_terms($node);
rsort($terms);
$myterm = $terms[0]->tid;
echo $myterm;
//to get other taxonomy properties from Array
print_r($terms);
?>
Sasha
Solution Studio