Hi,

i can't limit the depth of sub-categories. He always displays all sub-categories and the containing nodes.

Comments

xpla’s picture

Oh i got the problem -> it's not a vocabulary, it's a menu. Is it possible to limit the depth of menu links?

Negor’s picture

I'm used unction from the menublock module to trim menu sitemap for depth. Here it

<?php
function menu_tree_depth_trim(&$tree, $depth_limit) {
 
// Prevent invalid input from returning a trimmed tree.
 
if ($depth_limit < 1) { return; }

 
// Examine each element at this level to find any possible children.
 
foreach (array_keys($tree) AS $key) {
    if (
$tree[$key]['below']) {
      if (
$depth_limit > 1) {
       
menu_tree_depth_trim($tree[$key]['below'], $depth_limit-1);
      }
      else {
       
// Remove the children items.
       
$tree[$key]['below'] = FALSE;
      }
    }
    if (
$depth_limit == 1 && $tree[$key]['link']['has_children']) {
     
// Turn off the menu styling that shows there were children.
     
$tree[$key]['link']['has_children'] = FALSE;
     
$tree[$key]['link']['leaf_has_children'] = TRUE;
    }
  }
}
?>
-Mania-’s picture

@Negor: Where are you supposed to add this code to make it work?