Elgg  Version master
Functions
navigation.php File Reference

Go to the source code of this file.

Functions

 elgg_register_menu_item (string $menu_name, array|\ElggMenuItem $menu_item)
 Elgg navigation library Functions for managing menus and other navigational elements. More...
 
 elgg_unregister_menu_item (string $menu_name, string $item_name)
 Remove an item from a menu. More...
 
 elgg_register_title_button (string $name= 'add', string $entity_type= '', string $entity_subtype= '')
 Convenience function for registering a button to the title menu. More...
 

Function Documentation

elgg_register_menu_item ( string  $menu_name,
array|\ElggMenuItem  $menu_item 
)

Elgg navigation library Functions for managing menus and other navigational elements.

Pagination Automatically handled by Elgg when using elgg_list_entities* functions.

See also
elgg_list_entities()

Tabs

See also
navigation/tabs view

Menus Elgg uses a single interface to manage its menus. Menu items are added with elgg_register_menu_item(). This is generally used for menus that appear only once per page. For dynamic menus (such as the hover menu for user's avatar), an event is emitted when the menu is being created. The event is 'register', 'menu:<menu_name>'. For more details on this,

See also
elgg_view_menu().

Menus supported by the Elgg core Standard menus: site Site navigation shown on every page. page Page menu usually shown in a sidebar. Uses Elgg's context. topbar Topbar menu shown on every page. The default has two sections. footer Like the topbar but in the footer.

Dynamic menus (also called just-in-time menus): user_hover Avatar hover menu. The user entity is passed as a parameter. entity The set of links shown in the summary of an entity. river Links shown on river items. owner_block Links shown for a user or group in their owner block. filter The tab filter for content (all, mine, friends) title The buttons shown next to a content title. longtext The links shown above the input/longtext view. login Menu of links at bottom of login box Register an item for an Elgg menu

Warning
Generally you should not use this in response to the event: 'register', 'menu:<menu_name>'. If you do, you may end up with many incorrect links on a dynamic menu.
A menu item's name must be unique per menu. If more than one menu item with the same name are registered, the last menu item takes priority.
See also
elgg_view_menu() for the plugin events available for modifying a menu as it is being rendered.
ElggMenuItem::factory() is used to turn an array value of $menu_item into an ElggMenuItem object.

The constructor and factory support the following array of menu item options: name => STR Menu item identifier (required) text => STR Menu item display text as HTML (required) href => STR Menu item URL (required) false = do not create a link. null = current URL. "" = current URL. "/" = site home page. contexts => ARR Page context strings section => STR Menu section identifier title => STR Menu item tooltip selected => BOOL Is this menu item currently selected parent_name => STR Identifier of the parent menu item link_class => STR A class or classes for the tag item_class => STR A class or classes for the tag deps => STR One or more ES modules to require

Additional options that the view output/url takes can be passed in the array. Custom options can be added by using the 'data' key with the value being an associative array.

Parameters
string$menu_nameThe name of the menu: site, page, userhover, userprofile, groupprofile, or any custom menu
mixed$menu_itemA object or an array of options
Returns
void
Since
1.8.0

Definition at line 83 of file navigation.php.

elgg_register_title_button ( string  $name = 'add',
string  $entity_type = '',
string  $entity_subtype = '' 
)

Convenience function for registering a button to the title menu.

The URL must be resolvable in a route definition with the name "$name:$entity_type:$entity_subtype". The label of the button is "$name:$entity_type:$entity_subtype" so that must be defined in a language file.

This is used primarily to support adding an add content button

Parameters
string$nameName of the button (defaults to 'add')
string$entity_typeOptional entity type to be added (used to verify canWriteToContainer permission)
string$entity_subtypeOptional entity subtype to be added (used to verify canWriteToContainer permission)
Returns
void
Since
1.8.0

Definition at line 120 of file navigation.php.

elgg_unregister_menu_item ( string  $menu_name,
string  $item_name 
)

Remove an item from a menu.

Parameters
string$menu_nameThe name of the menu
string$item_nameThe unique identifier for this menu item
Returns
|null
Since
1.8.0

Definition at line 100 of file navigation.php.