You are here

function taxonomy_menu_block_nodes in Taxonomy menu block 7

Attach nr. of nodes to each term, plus the optional node options.

Parameters

type $tree:

type $config:

Return value

type

1 call to taxonomy_menu_block_nodes()
taxonomy_menu_block_build in ./taxonomy_menu_block.module
Function to build our tree.

File

./taxonomy_menu_block.module, line 548
Taxonomy Menu Block module allows you to make menu blocks out of your taxonomies in a very performant way.

Code

function taxonomy_menu_block_nodes($tree, $config) {

  // Get the node count.
  $tids = array_keys($tree);
  $nodes = taxonomy_menu_block_get_nodes($tids, $config['vid'], $config['ctype']);

  // Add the "normal" node count.
  foreach ($tree as $tid => $term) {
    $tree[$tid]['nodes'] = 0;
    if (isset($nodes[$tid])) {
      $tree[$tid]['nodes'] = $nodes[$tid];
    }
  }

  // Add the aggregation node count.
  if ($config['nodes_aggregation']) {
    foreach ($tree as $tid => $term) {

      // Only aggregate if we have a parent and if the term is present in the
      // current tree.
      $parent_tid = $term['parents'][0];
      if (isset($tree[$parent_tid]) && $parent_tid != '0') {
        $tree[$parent_tid]['nodes'] = $tree[$parent_tid]['nodes'] + $term['nodes'];
      }
    }
  }
  return $tree;
}