| Alexey Borzov 2007-09-18, 7:09 pm |
| Hi,
Mark Reynolds wrote:
> I have an array which I'm trying to display as a 'Tree' menu via 'HTML
> Menu' (example of the actual tree menu below, the array is below that). I've
> come across a few problems. Firstly, as you would expect when the 'tree'
> menu is displayed it displays three levels. Because I'm using the
> DirectTreeRenderer the menu is displayed in a list and I'm trying to find a
> way of just displaying 2 levels. Is this something I can limit as part of
> HTML menu or is it something I have to put in place when creating the actual
> array and if so, how do I do it? I've looked at
You can use something like this on $structure array you get from NestedSet
before passing it to HTML_Menu:
function trimTree(&$tree, $level)
{
foreach (array_keys($tree) as $key) {
if (!empty($tree[$key]['sub'])) {
if (1 == $level) {
unset($tree[$key]['sub']);
} else {
$this->trimTree($tree[$key]['sub'], $level - 1);
}
}
}
}
|