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 hooks 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.
__ http://reference.elgg.org/engine_2lib_2navigation_8php.html#a344445364078d03607904c44bad36c1c
__ http://reference.elgg.org/engine_2lib_2navigation_8php.html#ae26ee09e330a130984c9a6f9e19f6546
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:: php
// Remove the "Elgg" logo from the topbar menu
elgg_unregister_menu_item('topbar', 'elgg_logo');
Advanced usage
==============
You can get more control over menus by using :doc:`plugin hooks `
and the public methods provided by the ElggMenuItem__ class.
There are two hooks that can be used to modify a menu:
- ``'register', 'menu: