I have a content type "News entry", which has a term reference "News category", which is of course a taxonomy vocabulary.

I’m not sure if I get this whole taxonomy thing right, but I’m able to render and theme each category correctly (/news/category-a).

Now I want to theme the overview or home page, which displays all news entries of all categories. Easiest way for me would be selecting the right rows out of the database, but I reckon that’s not very much the Drupal way.

So I figured out how to get all terms of a vocabulary. In the preprocessing function theme_preprocess_node_news_overview() I tried taxonomy_get_tree(). Now I've got an object for each term with the following contents:

https://i.sstatic.net/cbT8c.png (can’t post images yet)

The news entries are preprocessed in theme_preprocess_node_news_post(), It’d be great if this function could be reused for the news overview.

And now I’m stuck. How do I get Drupal to behave like it’s displaying a category/tax. term, but instead of the nodes of one term get (and display) the nodes of all terms?

1 Answer 1


As "all linked nodes from all terms" are in my case the same as "all nodes of a content type", I solved my problem this way:

function themename_preprocess_node_news_overview(&$vars) {
  $results = db_query("SELECT nid, type FROM {node} WHERE type = 'news_post';");
  $tmp = array();
  foreach ($results as $result) {
    $tmp[] = $result->nid;
  $vars['content'] = node_view_multiple(node_load_multiple($tmp), 'teaser');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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