hypejunction/menus_api

Menus API

1.1.1 2016-02-10 19:25 UTC

This package is auto-updated.

Last update: 2024-11-29 03:58:22 UTC


README

Elgg 2.0

Various convenient functions and views for working with menus

Title Menu

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