hypejunction / menus_api
Menus API
Installs: 63
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 1
Open Issues: 0
Type:elgg-plugin
Requires (Dev)
- composer/installers: 1.*
This package is auto-updated.
Last update: 2024-11-29 03:58:22 UTC
README
Various convenient functions and views for working with menus
Usage
Combine menus
$menu_items = menus_api_combine_menus([ 'entity', 'owner_block', 'user_hover' ], [ 'entity' => $user, ]);
Get menu items
$params = menus_api_prepare_params('user_hover', ['entity' => 'user]); $items = menus_api_get_menu('user_hover', $params);
Add icon and indicator
$item = ElggMenuItem::factory([ 'name' => 'messages', 'text' => 'New messages', 'href' => '/messages', 'data' => [ 'indicator' => 5, 'icon' => 'envelope', 'require' => ['js/menu/module'], ] ]);
Only show certain menu sections
echo menus_api_view_menu('user_hover', [ 'entity' => $user, 'sections' => ['admin', 'action'], 'sort_by' => 'priority', ]);
Child menu subsections
You can break down child menus into subsections, and list them in a predefined order.
$parent = ElggMenuItem::factory([ 'name' => 'parent', 'text' => 'Parent', 'data' => [ 'subsections' => ['actions', 'admin'] ] ]); $item = ElggMenuItem::factory([ 'name' => 'action', 'parent_name' => 'parent', 'text' => 'Action', 'data' => [ 'subsection' => 'actions' ] ]);
Note
- This plugin replaces the default menu, section and item views