I need to get the terms a node has. I found out that you can use this:
$result = field_view_field('node', $node, 'field_tags', array('default'));
But this prints a rendered list. I need the names, or tids.
How do I separate them?
Drupal Answers is a question and answer site for Drupal developers and administrators. It only takes a minute to sign up.Sign up to join this community
The structure of a taxonomy field in a node is similar to the following one:
The first array index is the identifier of the language associated with the taxonomy, or "und" (the value of the constant LANGUAGE_NONE) if the taxonomy term doesn't have any associated language.
Searching on api.drupal.org I see there is a
field_get_items('node', $node, 'field_tags');that you could use.
You can also inspect the $node object and get the values directly from there. To inspect the
$node object I recommend you install the devel module and then use the dpm or krumo function like: