當前位置: 首頁>>代碼示例>>PHP>>正文


PHP CMSMenu::menu_items方法代碼示例

本文整理匯總了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;
 }
開發者ID:racontemoi,項目名稱:shibuichi,代碼行數:28,代碼來源:CMSMenu.php


注:本文中的CMSMenu::menu_items方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。