While you can easily make a query result where vid=vocabularyId I'd like to know if there's a method in the api to do so so my code looks a bit less ugly. I'd like to know if theres something like vocabulary_get_nodes(vid) already implemented in Drupal's core.
views:
39answers:
1
+4
A:
Not sure this is exactly what you want to do, but check out these three API functions:
If you search api.drupal.org, there are several other vocabulary related API functions as well, just search for the ones that begin with taxonomy_
bkildow
2010-06-22 17:45:55
+1 for 'taxonomy_select_nodes()' - it should be added that this returns a query result resource, so one needs to add some code to extract the nodes: http://stackoverflow.com/questions/3050741/getting-an-array-of-nodes-related-to-a-category-term-with-the-drupal-api/3051161#3051161
Henrik Opel
2010-06-22 18:19:06
Getting all terms and then aggregating the nodes seems to be the only way if the HAS to be used. I ended up querying the nodes myself.Thanks!
JoseMarmolejos
2010-06-22 22:09:22
On Drupal 6 and 5, the query used by taxonomy_select_nodes() will use db_query_range() or pager_query(). If you really need to retrieve all nodes, you will need to call it multiple times, one for each results 'page'. pager_query() will user $_GET['page'] as page index and will store the number of pages in (global) $pager_total[0].Note that if the list of nodes is displayed on a page, paging is a good thing. In this case, simply uses a single call to taxonomy_select_nodes() and don't forget to include a pager on the rendered page (using theme_pager()).
mongolito404
2010-06-23 05:54:49