Actions

Extra menus event: Difference between revisions

From LimeSurvey Manual

No edit summary
No edit summary
Line 12: Line 12:


Plugin will set property <code>extraMenus</code>. Each element in that array must implement interface <code>ExtraMenuInterface</code>.
Plugin will set property <code>extraMenus</code>. Each element in that array must implement interface <code>ExtraMenuInterface</code>.
== Example ==


This example with create a dropdown menu with three empty menu items and one divider:
This example with create a dropdown menu with three empty menu items and one divider:
Line 32: Line 34:
));
));
</syntaxhighlight>
</syntaxhighlight>
== Interfaces ==


{|
{|

Revision as of 22:41, 25 April 2016

Description of the event to generate extra menus at top bar (besides configuration, logout, etc).

Two types of menus:

  • Dropdown
  • Link

For dropdown, we have two kinds of menu items:

  • Link
  • Divider

The event itself is called beforeAdminMenuRender.

Plugin will set property extraMenus. Each element in that array must implement interface ExtraMenuInterface.

Example

This example with create a dropdown menu with three empty menu items and one divider:

$event = $this->getEvent();
$event->set('extraMenus', array(
    new ExtraMenu(null)
));
$event->set('extraMenus', array(
  new ExtraMenu(array(
    'isDropDown' => true,
    'menuItems' => array(
        new ExtraMenuItem(null),
        new ExtraMenuItem(null),
        new ExtraMenuItem(array('isDivider' => true)),
        new ExtraMenuItem(null)
    )
  ))
));

Interfaces

Method Description
isDropDown Returns true if this menu is a dropdown menu
getLabel Returns the actual name of the menu
getHref If it's not a dropdown menu, this is just for the link
getMenuItems Return array of dropdown menu items

Each menu item returned by getMenuItems must implement the interface ExtraMenuItemInterface

Method Description
getHref As above, used for link in dropdown item
getLabel The text for the link