I'm having a very peculiar problem where some taxonomies are not returning any nodes using the views_embed_view() function, while most are returning correctly.

First let me explain how i have things setup.

From what I've been able to ascertain views has difficulty displaying nested taxonomies in their correct order but I've worked around that by creating my simple view that has the term-id as an argument and looping through my taxonomy in the correct order to output them via php and the views_embed_view() function.

For reference, my php is as follows:

<?php
$vid = 1;  // Set the vid to the vocabulary id of the vocabulary you wish to list the terms from
$parent = 0;
$depth = -1;
$max_depth = 1;  // Setting to 1 returns top level terms only (in relation $parent)
                 // as all others will be acquired using taxonomy_get_children()
$term = array();  // Will hold the term id argument to be passed to the view
$terms1 = taxonomy_get_tree ($vid, $parent, $depth, $max_depth);
foreach ($terms1 as $term1) {
  print '<div class="term-parent">' . $term1->name . '</div>';
  $term[0] = $term1->tid;
  print views_embed_view('productlist', 'default', $term[0]);
  if (count ($terms2 = taxonomy_get_children ($term1->tid, $vid))) {
    foreach ($terms2 as $term2) {
      print '<div class="term-child">' . $term2->name . '</div>';
      $term[0] = $term2->tid;
      print views_embed_view('uc_products_custom', 'default', $term[0]);
    }
  }
}
?>

The page I'm working on can be found at http://www.cibus.co.th/price-list (I'm aware it doesn't look very nice, but it's not intended for customers to see, only for staff to print).

As an example of what I'm talking about, if you scroll down you'll see that there are no entries under Vinegars but if you visit http://www.cibus.co.th/catalog/54 you'll see that there are four nodes under that term. The same applies to Balsamic Vinegars, which have many nodes at http://www.cibus.co.th/catalog/55.

What might be causing this and how can I get the invisible nodes to display correctly? It's doubly frustrating because most taxonomies are returning the correct nodes. Any ideas?

Comments

harrisben’s picture

Nevermind, I realised that it was the parent terms not returning any nods because I was calling the wrong view.