From b6b9036821e4874e6a65c7508d3b168ce0aa4873 Mon Sep 17 00:00:00 2001 From: Mikael Nordfeldth Date: Sat, 14 Feb 2015 17:32:35 +0100 Subject: [PATCH] StartSubMenu and EndSubMenu events --- EVENTS.txt | 9 +++++++++ lib/menu.php | 12 ++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/EVENTS.txt b/EVENTS.txt index b98c6ff52f..9a6ddfd9a4 100644 --- a/EVENTS.txt +++ b/EVENTS.txt @@ -1472,3 +1472,12 @@ EndHomeStubNavItems: - $action: action being executed (for output and params) - $items: array of items in the nav +EndSubMenu: After outputting a submenu (including enclosing tags) to HTML +- $out: HTMLOutputter used to output (usually an Action, but not always!) +- $menu: The Menu object outputted as a submenu. +- $label: Localized text which represents the menu item. + +StartSubMenu: Before outputting a submenu (including enclosing tags) to HTML +- $out: HTMLOutputter used to output (usually an Action, but not always!) +- $menu: The Menu object outputted as a submenu. +- $label: Localized text which represents the menu item. diff --git a/lib/menu.php b/lib/menu.php index 4baeb70d2f..236e99263d 100644 --- a/lib/menu.php +++ b/lib/menu.php @@ -150,12 +150,12 @@ class Menu extends Widget function submenu($label, $menu) { - if (empty($menu->getItems())){ - return false; + if (Event::handle('StartSubMenu', array($this->action, $menu, $label))) { + $this->action->elementStart('li'); + $this->action->element('h3', null, $label); + $menu->show(); + $this->action->elementEnd('li'); + Event::handle('EndSubMenu', array($this->action, $menu, $label)); } - $this->action->elementStart('li'); - $this->action->element('h3', null, $label); - $menu->show(); - $this->action->elementEnd('li'); } }