Hi,

I am using following code to display taxonomy terms associated to a node inside a block

/**
 * Prints an unordered list of the terms (as links) that are
 * associated to the currently displayed node.
 */
if ( arg(0) == 'node' && is_numeric(arg(1)) ) {
    $node = node_load(arg(1));
    if (module_exists('taxonomy')) {
        $terms = taxonomy_link('taxonomy terms', $node);
        print theme('links', $terms, array('class' => 'node-terms'));
    } else {
        print 'No associated categories.';
    }
}

I have 2 vocabulary - topics and author. I want only terms inside topics get listed. Is it possible?

Thanks

Comments

sapark’s picture

maybe taxonomy_node_get_terms_by_vocabulary() http://api.drupal.org/api/function/taxonomy_node_get_terms_by_vocabulary/6 - Find all terms associated with the given node, within one vocabulary.

pushkarpathak’s picture

I got success in implementing the function

/**
 * Prints an unordered list of the terms (as links) that are
 * associated to the currently displayed node.
 */
if ( arg(0) == 'node' && is_numeric(arg(1)) ) {
    $node = node_load(arg(1));
    $vid = 2;
    $terms = taxonomy_node_get_terms_by_vocabulary($node, $vid);
    if ($terms) {
print '<ul>';
                foreach ($terms as $term) {
                print '<li>'.l($term->name, 'taxonomy/term/'.$term->tid).'</li>';

          }
print '</ul>';
    } 
}
Anonymous’s picture

Couldn't you put this option into node.tpl.php?