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


PHP widgets\Menu类代码示例

本文整理汇总了PHP中yii\widgets\Menu的典型用法代码示例。如果您正苦于以下问题:PHP Menu类的具体用法?PHP Menu怎么用?PHP Menu使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: run

 /**
  * @inheritdoc
  */
 public function run()
 {
     $items = [['label' => 'Основные', 'url' => ['/user/settings/profile']], ['label' => 'Уведомления', 'url' => ['/user/settings/notifications']]];
     echo '<nav class="menu">';
     echo '<h3 class="menu-heading">Разделы настроек</h3>';
     echo Menu::widget(['items' => $items, 'itemOptions' => ['class' => 'menu-item'], 'activeCssClass' => 'selected']);
     echo "</nav>";
 }
开发者ID:marley-php,项目名称:linuxforum,代码行数:11,代码来源:SettingsMenu.php

示例2: run

 /**
  * Renders the menu.
  */
 public function run()
 {
     // Get Module list
     $modules = array_keys(Yii::$app->modules);
     // Get sub menu for each module
     foreach ($modules as $moduleName) {
         // Get module
         $moduleObj = Yii::$app->getModule($moduleName);
         $iconClass = isset($moduleObj->iconClass) ? $moduleObj->iconClass : 'fa-dashboard';
         // Get menu
         if (property_exists($moduleObj, 'backendMenu')) {
             $getModule = Yii::$app->request->get('module');
             $item = ['label' => Icon::show($iconClass) . '<span class="nav-label">' . Yii::t($moduleName, ucfirst($moduleName)) . '</span>', 'url' => ['/' . $moduleName . '/default']];
             if (Yii::$app->controller->module->id == $moduleName and empty($getModule) or $getModule == $moduleName) {
                 $item['active'] = TRUE;
             }
             $backendMenu = $moduleObj->backendMenu;
             if (is_array($backendMenu)) {
                 foreach ($backendMenu as $itemMenu) {
                     if (isset($itemMenu['access']) and $this->checkAccess($itemMenu['access'])) {
                         $item['items'][] = ['label' => $itemMenu['label'], 'url' => $itemMenu['url']];
                     }
                 }
                 if (isset($item['items']) and !empty($item['items'])) {
                     $item['label'] .= '<span class="fa arrow"></span>';
                 }
             }
             // assign to $this->items
             $this->items[] = $item;
         }
     }
     parent::run();
 }
开发者ID:quynhvv,项目名称:stepup,代码行数:36,代码来源:BackendMenu.php

示例3: run

 /**
  * @inheritdoc
  */
 public function run()
 {
     echo $this->beforeWidget;
     if ($this->title) {
         echo $this->beforeTitle . $this->title . $this->afterTitle;
     }
     echo Menu::widget(['items' => [['label' => 'Site Admin', 'url' => Yii::$app->urlManagerBack->baseUrl, 'visible' => !Yii::$app->user->isGuest], ['label' => 'Login', 'url' => Yii::$app->urlManagerBack->createUrl(['/site/login']), 'visible' => Yii::$app->user->isGuest], ['label' => 'Logout', 'url' => Yii::$app->urlManager->createUrl(['/site/logout']), 'visible' => !Yii::$app->user->isGuest, 'template' => '<a href="{url}" data-method="post">{label}</a>'], ['label' => 'WritesDown.com', 'url' => 'http://www.writesdown.com/']]]);
     echo $this->afterWidget;
 }
开发者ID:tampaphp,项目名称:app-cms,代码行数:12,代码来源:MetaWidget.php

示例4: testTagOption

    /**
     * @see https://github.com/yiisoft/yii2/issues/8064
     */
    public function testTagOption()
    {
        $output = Menu::widget(['route' => 'test/test', 'params' => [], 'encodeLabels' => true, 'options' => ['tag' => false], 'items' => [['label' => 'item1', 'url' => '#', 'options' => ['tag' => 'div']], ['label' => 'item2', 'url' => '#', 'options' => ['tag' => false]]]]);
        $this->assertEqualsWithoutLE(<<<HTML
<div><a href="#">item1</a></div>
<a href="#">item2</a>
HTML
, $output);
    }
开发者ID:howq,项目名称:yii2,代码行数:12,代码来源:MenuTest.php

示例5: run

 /**
  * @inheritdoc
  */
 public function run()
 {
     $sortBy = Yii::$app->request->get('sort_by', 'new');
     $items[] = ['label' => 'Активные', 'url' => Url::current(['sort_by' => 'new']), 'active' => $sortBy == 'new', 'options' => ['title' => 'Темы отсортированные по времени последнего сообщения']];
     $items[] = ['label' => 'Без ответов', 'url' => Url::current(['sort_by' => 'unanwser']), 'active' => $sortBy == 'unanwser', 'options' => ['title' => 'Темы отсортированные по времени последнего сообщения и не содержащие ответов']];
     if (!Yii::$app->getUser()->getIsGuest()) {
         $items[] = ['label' => 'Мои', 'url' => Url::current(['sort_by' => 'own']), 'active' => $sortBy == 'own', 'options' => ['title' => 'Темы отсортированные по времени последнего сообщения и не содержащие ответов']];
     }
     return Menu::widget(['items' => $items, 'options' => ['class' => 'question-list-tabs']]);
 }
开发者ID:marley-php,项目名称:linuxforum,代码行数:13,代码来源:Tabs.php

示例6: run

 /**
  * Renders the widget.
  */
 public function run()
 {
     echo Html::beginTag('div', ['class' => 'page-sidebar-wrapper']);
     echo Html::beginTag('div', ['class' => 'page-sidebar navbar-collapse collapse']);
     echo Menu::widget(['items' => $this->items, 'encodeLabels' => false, 'options' => ['class' => 'page-sidebar-menu', 'data-keep-expanded' => "false", 'data-auto-scroll' => "true", 'data-slide-speed' => 200], 'submenuTemplate' => "\n<ul class=\"sub-menu\">\n{items}\n</ul>\n"]);
     echo Html::endTag('div');
     // page-sidebar-wrapper
     echo Html::endTag('div');
     // page-sidebar
 }
开发者ID:anli,项目名称:yii2-metronic,代码行数:13,代码来源:Sidebar.php

示例7: init

 /**
  *
  */
 public function init()
 {
     parent::init();
     foreach ($this->items as $i => &$item) {
         if (isset($item['url'])) {
             if (isset($item['items'])) {
                 // Menu
                 $item['options'] = isset($item['options']) ? $item['options'] : [];
                 Html::addCssClass($item['options'], 'treeview');
                 if (!isset($item['icon'])) {
                     $item['icon'] = $this->defaultMenuIcon;
                 }
                 // Submenu
                 foreach ($item['items'] as $j => &$subItem) {
                     if (isset($subItem['icon'])) {
                         $subItem['label'] = "{$subItem['icon']} {$subItem['label']}";
                     } else {
                         $subItem['label'] = "{$this->subLinkIcon} {$subItem['label']}";
                     }
                     if (isset($subItem['items'])) {
                         $subItem['options'] = isset($subItem['options']) ? $subItem['options'] : [];
                         Html::addCssClass($subItem['options'], 'treeview');
                         foreach ($subItem['items'] as $k => &$subSubItem) {
                             if (isset($subSubItem['icon'])) {
                                 $subSubItem['label'] = "{$subSubItem['icon']} {$subSubItem['label']}";
                             } else {
                                 $subSubItem['label'] = "{$this->subLinkIcon} {$subSubItem['label']}";
                             }
                         }
                     }
                 }
             } else {
                 // Link
                 if (!isset($item['icon'])) {
                     $item['icon'] = $this->defaultLinkIcon;
                 }
                 if (isset($item['badge'])) {
                     $label = $item['badge']['content'];
                     $type = isset($item['badge']['type']) ? $item['badge']['type'] : $this->defaultBadgeType;
                     $item['badge'] = "<small class=\"label pull-right {$type}\">{$label}</small>";
                 } else {
                     $item['badge'] = '';
                 }
             }
             // Icon
             $item['label'] = "{$item['icon']} <span>{$item['label']}</span>";
         } else {
             // Label
             $item['options'] = isset($item['options']) ? $item['options'] : [];
             Html::addCssClass($item['options'], 'header');
         }
     }
 }
开发者ID:sacara,项目名称:yii2-admin-lte-1,代码行数:56,代码来源:Menu.php

示例8: init

 public function init()
 {
     parent::init();
     $category = Category::findOne(83);
     $descendants = $category->children()->all();
     $menuItems = [];
     foreach ($descendants as $key => $value) {
         $menuItems[] = ['label' => $value->name, 'url' => ['post/index', 'id' => $value->id]];
     }
     $menuItems[] = ['label' => '未分类', 'url' => ['post/index', 'id' => 0]];
     echo '<h4 class="text-right">分类</h4>';
     echo Menu::widget(['options' => ['class' => 'side-menu list-unstyled'], 'items' => $menuItems, 'encodeLabels' => false]);
 }
开发者ID:rocketyang,项目名称:dcms2,代码行数:13,代码来源:CategoryWidget.php

示例9: isItemActive

 protected function isItemActive($item)
 {
     if ($item['url'] == Url::to('')) {
         return true;
     } elseif (isset($item['url']) && is_array($item['url']) && isset($item['url'][0])) {
         $route = $item['url'][0];
         if ($route[0] !== '/' && Yii::$app->controller) {
             $route = Yii::$app->controller->module->getUniqueId() . '/' . $route;
         }
         if (ltrim($route, '/') !== $this->route) {
             return false;
         }
         unset($item['url']['#']);
         if (count($item['url']) > 1) {
             $params = $item['url'];
             unset($params[0]);
             foreach ($params as $name => $value) {
                 if ($value !== null && (!isset($this->params[$name]) || $this->params[$name] != $value)) {
                     return false;
                 }
             }
         }
         return true;
     } else {
         return parent::isItemActive($item);
     }
 }
开发者ID:oakcms,项目名称:oakcms,代码行数:27,代码来源:Menu.php

示例10: isItemActive

 protected function isItemActive($item)
 {
     if (is_string($item['url'])) {
         return $item['url'] === Yii::$app->request->url;
     } else {
         return parent::isItemActive($item);
     }
 }
开发者ID:heartshare,项目名称:dotplant2,代码行数:8,代码来源:Menu.php

示例11: __construct

 public function __construct($config = array())
 {
     parent::__construct($config);
     $categories = Category::find()->all();
     foreach ($categories as $category) {
         $this->items[] = ['label' => $category->caption, 'url' => ['/product/category/' . $category->machine_name]];
     }
 }
开发者ID:AsterAI-corp,项目名称:category,代码行数:8,代码来源:MainMenu.php

示例12: init

 /**
  * Initializes the menu widget.
  * This method mainly normalizes the {@link items} property.
  * If this method is overridden, make sure the parent implementation is invoked.
  */
 public function init()
 {
     parent::init();
     $this->options['role'] = 'menu';
     if (isset($this->options['class'])) {
         $this->options['class'] .= ' page-sidebar-menu';
     } else {
         $this->options['class'] = 'page-sidebar-menu';
     }
 }
开发者ID:appxq,项目名称:yii2-sidebar,代码行数:15,代码来源:SDSidebar.php

示例13: renderItem

 /**
  * @inheritdoc
  */
 protected function renderItem($item)
 {
     $renderedItem = parent::renderItem($item);
     if (isset($item['badge'])) {
         $badgeOptions = ArrayHelper::getValue($item, 'badgeOptions', []);
         Html::addCssClass($badgeOptions, 'label pull-right');
     } else {
         $badgeOptions = null;
     }
     return strtr($renderedItem, ['{icon}' => isset($item['icon']) ? new Icon($item['icon'], ArrayHelper::getValue($item, 'iconOptions', [])) : '', '{badge}' => (isset($item['badge']) ? Html::tag('small', $item['badge'], $badgeOptions) : '') . (isset($item['items']) && count($item['items']) > 0 ? new Icon('fa fa-angle-left pull-right') : '')]);
 }
开发者ID:yiister,项目名称:yii2-adminlte,代码行数:14,代码来源:Menu.php

示例14: init

 public function init()
 {
     parent::init();
     AffixAsset::register($this->getView());
     $this->activateParents = true;
     $this->submenuTemplate = "\n<ul class='nav'>\n{items}\n</ul>\n";
     $this->linkTemplate = '<a href="{url}">{icon}{label}</a>';
     $this->labelTemplate = '{icon}{label}';
     Html::addCssClass($this->options, 'nav kv-nav');
     Html::addCssClass($this->container, 'kv-sidebar hidden-print-affix');
 }
开发者ID:CBETOBuT,项目名称:yii2-widgets,代码行数:11,代码来源:Affix.php

示例15: init

 /**
  * Initializes the widget.
  */
 public function init()
 {
     parent::init();
     if ($this->route === null && Yii::$app->controller !== null) {
         $this->route = Yii::$app->controller->getRoute();
     }
     if ($this->params === null) {
         $this->params = $_GET;
     }
     Html::addCssClass($this->options, 'nav');
 }
开发者ID:pramana08,项目名称:yii2-foundation-topbar,代码行数:14,代码来源:FoundationNav.php


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