Fix for ticket #366

1) Stored the menu element type in the menu element
2) Scanned the menu before display removing any empty sub menus.
Went with the removal approach because there will more users than developers

Signed-off-by:  <unostar@danalan.info>
This commit is contained in:
Tim Almdal
2009-06-18 16:29:39 +08:00
committed by
parent 753ce3e025
commit e2863cf1c5
2 changed files with 26 additions and 7 deletions
+14
View File
@@ -103,11 +103,25 @@ class Theme_View_Core extends View {
call_user_func_array(array($class, "site"), array(&$menu, $this));
}
}
$this->_remove_empty_items($menu);
}
print $menu;
}
private function _remove_empty_items($menu) {
foreach ($menu->elements as $target_id => $element) {
if ($element->type == "submenu") {
if (empty($element->elements)) {
$menu->remove($target_id);
} else {
$this->_remove_empty_items($element);
}
}
}
}
public function album_menu() {
$this->_menu("album");
}