STR Menu item identifier (required) * title => STR Menu item title (required) * url => STR Menu item URL (required) * contexts => ARR Page context strings * section => STR Menu section identifier * tooltip => STR Menu item tooltip * selected => BOOL Is this menu item currently selected * parent_name => STR Identifier of the parent menu item * * Custom options can be added as key value pairs. * * @return bool * @since 1.8.0 */ function elgg_register_menu_item($menu_name, $menu_item) { global $CONFIG; if (!isset($CONFIG->menus[$menu_name])) { $CONFIG->menus[$menu_name] = array(); } if (is_array($menu_item)) { $menu_item = ElggMenuItem::factory($menu_item); if (!$menu_item) { return false; } } $CONFIG->menus[$menu_name][] = $menu_item; return true; } /** * Remove an item from a menu * * @param string $menu_name The name of the menu * @param string $item_name The unique identifier for this menu item * * @return bool * @since 1.8.0 */ function elgg_unregister_menu_item($menu_name, $item_name) { global $CONFIG; if (!isset($CONFIG->menus[$menu_name])) { return false; } foreach ($CONFIG->menus[$menu_name] as $index => $menu_object) { if ($menu_object->name == $item_name) { unset($CONFIG->menus[$menu_name][$index]); return true; } } return false; } /** * Deprecated by elgg_add_submenu_item() * * @see elgg_add_submenu_item() * @deprecated 1.8 * * @param string $label The label * @param string $link The link * @param string $group The group to store item in * @param boolean $onclick Add a confirmation when clicked? * @param boolean $selected Is menu item selected * * @return bool */ function add_submenu_item($label, $link, $group = 'default', $onclick = false, $selected = NULL) { elgg_deprecated_notice('add_submenu_item was deprecated by elgg_add_submenu_item', 1.8); // submenu items were added in the page setup hook usually by checking // the context. We'll pass in the current context here, which will // emulate that effect. // if context == 'main' (default) it probably means they always wanted // the menu item to show up everywhere. $context = elgg_get_context(); if ($context == 'main') { $context = 'all'; } $item = array( 'name' => $label, 'title' => $label, 'url' => $link, 'context' => $context, 'section' => $group, ); if ($selected) { $item['selected'] = true; } if ($onclick) { $js = "onclick=\"javascript:return confirm('" . elgg_echo('deleteconfirm') . "')\""; $item['vars'] = array('js' => $js); } return elgg_register_menu_item('page', $item); /* $item = array( 'text' => $label, 'href' => $link, 'selected' => $selected ); return elgg_add_submenu_item($item, $context, $group); * */ } /** * Add an entry to the submenu. * * @param array $item The item as: * * array( * 'title' => 'Text to display', * 'url' => 'URL of the link', * 'id' => 'entry_unique_id' //used by children items to identify parents * 'parent_id' => 'id_of_parent', * 'selected' => BOOL // Is this item selected? (If NULL or unset will attempt to guess) * 'vars' => array() // Array of vars to pass to the navigation/submenu_item view * ) * * * @param string $context Context in which to display this menu item. 'all' * will make it show up all the time. Use sparingly. * @param string $group Group for the item. Each submenu group has its own