Menus
#####
Elgg contains helper code to build menus throughout the site.
Every single menu requires a name, as does every single menu item. These are
required in order to allow easy overriding and manipulation, as well as to
provide events for theming.
.. contents:: Contents
:local:
:depth: 1
Basic usage
===========
Basic functionalities can be achieved through these two functions:
- ``elgg_register_menu_item()`` to add an item to a menu
- ``elgg_unregister_menu_item()`` to remove an item from a menu
You normally want to call them from your plugin's init function.
Examples
--------
.. code-block:: php
// Add a new menu item to the site main menu
elgg_register_menu_item('site', array(
'name' => 'itemname',
'text' => 'This is text of the item',
'href' => '/item/url',
));
.. code-block:: php
// Remove the "Elgg" logo from the topbar menu
elgg_unregister_menu_item('topbar', 'elgg_logo');
Admin menu
==========
You can also register ``page`` menu items to the admin backend menu. When registering for the admin menu you can set the context of
the menu items to ``admin`` so the menu items only show in the ``admin`` context. There are 3 default sections to add your menu items to.
- ``administer`` for daily tasks, user management and other actionable tasks
- ``configure`` for settings, configuration and utilities that configure stuff
- ``information`` for statistics, overview of information or status
Advanced usage
==============
Headers
-------
For accessibility reasons each menu will get an ``aria-label`` which defaults to the menu name, but can be translated by making sure
the language key ``menu: