本文整理汇总了PHP中CMSMenu::menu_items方法的典型用法代码示例。如果您正苦于以下问题:PHP CMSMenu::menu_items方法的具体用法?PHP CMSMenu::menu_items怎么用?PHP CMSMenu::menu_items使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CMSMenu
的用法示例。
在下文中一共展示了CMSMenu::menu_items方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: replace_menu_item
/**
* Replace a navigation item to the main administration menu showing in the top bar.
*
* @param string $code Unique identifier for this menu item (e.g. used by {@link replace_menu_item()} and
* {@link remove_menu_item}. Also used as a CSS-class for icon customization.
* @param string $menuTitle Localized title showing in the menu bar
* @param string $url A relative URL that will be linked in the menu bar.
* Make sure to add a matching route via {@link Director::addRules()} to this url.
* @param string $controllerClass The controller class for this menu, used to check permisssions.
* If blank, it's assumed that this is public, and always shown to users who
* have the rights to access some other part of the admin area.
* @return boolean Success
*/
public static function replace_menu_item($code, $menuTitle, $url, $controllerClass = null, $priority = -1)
{
$menuItems = self::$menu_items;
$menuItems[$code] = new CMSMenuItem($menuTitle, $url, $controllerClass, $priority);
$menuPriority = array();
$i = 0;
foreach ($menuItems as $key => $menuItem) {
$i++;
// This funny litle formula ensures that the first item added with the same priority will be left-most.
$menuPriority[$key] = $menuItem->priority * 100 - $i;
}
array_multisort($menuPriority, SORT_DESC, $menuItems);
self::$menu_items = $menuItems;
return true;
}