taxonomy_node_get_terms_by_vocabulary

dangibas - April 1, 2008 - 02:17

Hi all,

I'm working inside a block with the following code (planning to make it a module later)...

<?php
$ArrayNodes
= array();
$ArrayNodes[] = $node->nid;
$terms = taxonomy_node_get_terms_by_vocabulary($ArrayNodes, 1);
foreach (
$terms as $term) {
 
$tags[] = l($term->name, taxonomy_term_path($term));
    }
//print t("Vocab 1 Terms") . ": " . implode(' | ', $tags);
print_r($tags);
?>

The objective is to display all nodes under a vocabulary - when I dont know the node id only the vocabulary id.

Example:

Vocab id = 1
|
------->term a
|___________A Node
|___________A Node

------->term b
|___________A Node
|___________A Node
------->term c
|___________A Node
|___________A Node

I just want to output the links to all of the nodes that are under Vocab id 1!

The code posted won't work because it requires that we know a node id or an array of node ids. When i pass in the array directly like so...

$terms = taxonomy_node_get_terms_by_vocabulary($node->nid, 1);

it fails for an unknown reason but if i hard code it like so...

$terms = taxonomy_node_get_terms_by_vocabulary(4, 1);

It works - but it only shows TERMS....

I think I'm looking for taxonomy_node_get_nodes_by_vocabulary() function - but does it exist!?

Any ideas how to make taxonomy_node_get_nodes_by_vocabulary() function?

Thanks and sorry for the long post - i was trying to understand it all as i was going :)

http://drupal.org/project/vocabulary_list_nodes

dangibas - April 1, 2008 - 02:30

Sometimes after hours of searching you find the solution 5 seconds after asking for help!

http://drupal.org/project/vocabulary_list_nodes

This module should totall be part of core distro!

Dan Gibas, HYGEN

You can also do the same

nevets - April 1, 2008 - 03:31

You can also do the same thing with the views module.

Tried it out

dangibas - April 1, 2008 - 03:37

Hi Nevets,

I did try that out however i'm not sure if it is a problem with my install or if I was going wrong, but after creating the view every time I navigated to it i got a page not found error. Couldn't get it to work in a block either :(

Dan Gibas, HYGEN

 
 

Drupal is a registered trademark of Dries Buytaert.