Select the latest node for each defined taxonomy term in Drupal 6

女生的网名这么多〃 提交于 2020-01-05 07:37:14

问题


Can anyone help me out with a query to display 1 node for each taxonomy in Drupal 6?

For example, I have 4 taxonomy terms (tid = 21, 22, 23, 24) in a 1 vocabulary (vid = 3).

I would like to display a table showing:

Taxonomy Term:

  1. Taxonomy
  2. Description
  3. Number of Nodes in Taxonomy Term
  4. Title of latest node in taxonomy term
  5. Last Commented/Updated Date

Thanks, JK


回答1:


Actually, just use http://drupal.org/project/views =) You don't need any hooks, etc.

and if you need to output this view in your custom module or whatever, you can do the following: create view, then call it programmatically:

  $view = views_get_view('view_name');
  $view->set_arguments(array($order->products[0]->nid)); // pass arguments to view, if it is required
  return $view->render('Defaults'); //return rendered view

OR

$view->execute();

After this, you can access rows data without HTML output in $view->result variable.

Hope this helps.



来源:https://stackoverflow.com/questions/6915237/select-the-latest-node-for-each-defined-taxonomy-term-in-drupal-6

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!