0

I have a node template with various taxonomy fields and I'm trying to get the term ID of a specific vocabulary field to pass it through an url. I have tried many function but I can't seem to find the proper one. Can anyone help me on this ?

  • Have you tried using the Devel module to help you find the fields? – kyletaylored Nov 2 '14 at 16:13
0

It sounds like you need to inspect your node. You can do this with the vital devel module.

https://www.drupal.org/project/devel

Once installed it will give you a few new tabs on your node page to see how the node is constructed when it is loaded using node_load($nid) and rendered using node_view($node).

In the node template itself, you will have access to the rendered node as per node_view($node) so anything you see in the devel modules render page you can print out in your node.tpl.php

Devel uses the excellent Krumo library to display PHP objects and array nicely, this is also accessible using dpm($object); however it can not be used in templates, but you can call krumo directly using krumo($node);

So in your node template, call krumo($node); to find the field you want, then once found add it to a variables $tid = $node->taxonomy[LANGUAGE_NONE][0]['tid']; and pass it to you link print l("taxonomy", "view/$tid");

-2
field_modele['und'][0]['tid']; ?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.