From: Mikael Nordfeldth Date: Sat, 14 Feb 2015 16:32:35 +0000 (+0100) Subject: StartSubMenu and EndSubMenu events X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=b6b9036821e4874e6a65c7508d3b168ce0aa4873;p=quix0rs-gnu-social.git StartSubMenu and EndSubMenu events --- 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'); } }