当前位置: 首页>>代码示例>>PHP>>正文


PHP FRoute::getMenus方法代码示例

本文整理汇总了PHP中FRoute::getMenus方法的典型用法代码示例。如果您正苦于以下问题:PHP FRoute::getMenus方法的具体用法?PHP FRoute::getMenus怎么用?PHP FRoute::getMenus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FRoute的用法示例。


在下文中一共展示了FRoute::getMenus方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getUrl

 public function getUrl($query, $url)
 {
     static $cache = array();
     // Get a list of menus for the current view.
     $itemMenus = FRoute::getMenus($this->name, 'item');
     // For single group item
     // index.php?option=com_easysocial&view=events&layout=item&id=xxxx
     $items = array('item', 'info', 'edit');
     if (isset($query['layout']) && in_array($query['layout'], $items) && isset($query['id']) && !empty($itemMenus)) {
         foreach ($itemMenus as $menu) {
             $id = (int) $menu->segments->id;
             $queryId = (int) $query['id'];
             if ($queryId == $id) {
                 // The query cannot contain appId
                 if ($query['layout'] == 'item' && !isset($query['appId'])) {
                     $url = 'index.php?Itemid=' . $menu->id;
                     return $url;
                 }
                 $url .= '&Itemid=' . $menu->id;
                 return $url;
             }
         }
     }
     // For group categories
     $menus = FRoute::getMenus($this->name, 'category');
     $items = array('category');
     if (isset($query['layout']) && in_array($query['layout'], $items) && isset($query['id']) && !empty($itemMenus)) {
         foreach ($menus as $menu) {
             $id = (int) $menu->segments->id;
             $queryId = (int) $query['id'];
             if ($queryId == $id) {
                 if ($query['layout'] == 'category') {
                     $url = 'index.php?Itemid=' . $menu->id;
                     return $url;
                 }
                 $url .= '&Itemid=' . $menu->id;
                 return $url;
             }
         }
     }
     return false;
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:42,代码来源:events.php

示例2: getItemId

 /**
  * Retrieves the item id of the current view.
  *
  * @since   1.0
  * @access  public
  * @param   string
  * @return
  */
 public static function getItemId($view, $layout = '', $id = '')
 {
     static $views = array();
     // Cache the result
     $key = $view . $layout . $id;
     if (!isset($views[$key])) {
         // Retrieve the list of default menu
         $defaultMenu = FRoute::getMenus('dashboard', '');
         // Initial menu should be false
         $menuId = false;
         if (!empty($layout)) {
             // Try to locate menu with just the view if we still can't find a menu id.
             $menus = FRoute::getMenus($view, $layout, $id);
             if (!$menuId && $menus) {
                 // If this menu contains data about "id", we shouldn't simply use it.
                 // if (!isset($menus[0]->segments->id)) {
                 //     $menuId     = $menus[0]->id;
                 // }
                 // var_dump($menus[0]);exit;
                 $menuId = $menus[0]->id;
             }
         }
         // Try to locate menu with just the view if we still can't find a menu id.
         $menus = FRoute::getMenus($view, '', '');
         // If menu id for view + layout doesn't exists, use the one from the view
         if (!$menuId && $menus) {
             $menuId = $menus[0]->id;
         }
         // If we still don't have a menu id, we use the default dashboard view.
         if (!$menuId && $defaultMenu) {
             $menuId = $defaultMenu[0]->id;
         }
         $views[$key] = $menuId;
     }
     return $views[$key];
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:44,代码来源:router.php


注:本文中的FRoute::getMenus方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。