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


PHP Menu::init方法代码示例

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


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

示例1: init

 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     if (!$this->items) {
         if (!$this->menu) {
             throw new InvalidParamException('Menu property must be set.');
         }
         $class = $this->menuModelClass;
         if (is_int($this->menu)) {
             $this->menu = $class::findOne($this->menu);
         } elseif (is_string($this->menu)) {
             $this->menu = $class::findBySlug($this->menu);
         }
         if ($this->menu instanceof $class) {
             //Get items
             $this->items = $this->menu->getItems();
             if ($this->beforeItems) {
                 $this->items = array_merge($this->beforeItems, $this->items);
             }
             if ($this->afterItems) {
                 $this->items = array_merge($this->items, $this->afterItems);
             }
             if (!empty($this->menu->element_id) && !isset($this->options['id'])) {
                 $this->options['id'] = $this->menu->element_id;
             }
             if (!empty($this->menu->css_class)) {
                 Html::addCssClass($this->options, $this->menu->css_class);
             }
         }
     }
 }
开发者ID:maddoger,项目名称:yii2-website,代码行数:34,代码来源:Menu.php

示例2: init

 /**
  * Initializes the widget.
  * If you override this method, make sure you call the parent implementation first.
  */
 public function init()
 {
     parent::init();
     if (!isset($this->options['id'])) {
         $this->options['id'] = $this->getId();
     }
 }
开发者ID:bmsrox,项目名称:yiicomm,代码行数:11,代码来源:Menu.php

示例3: 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

示例4: 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

示例5: 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

示例6: init

 /**
  * Initializes this widget.
  */
 public function init()
 {
     parent::init();
     if (empty($this->items)) {
         $this->items = $this->getItems();
     }
     $this->encodeLabels = false;
     $this->activateParents = true;
     $this->submenuTemplate = "\n<ul class=\"treeview-menu\">\n{items}\n</ul>\n";
     $this->options = ['class' => 'sidebar-menu'];
 }
开发者ID:bigbrush,项目名称:yii2-cmf,代码行数:14,代码来源:AdminMenu.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()
 {
     if ($this->renderCategories) {
         $categories = Category::findAll(['parent_id' => $this->categoryId, 'show' => true]);
         $this->items = array_merge($this->items, $this->handleCategories($categories));
     }
     if ($this->renderArticles) {
         $articles = Article::find()->where(['category_id' => $this->categoryId, 'show' => true])->orderBy(['position' => SORT_ASC])->all();
         $this->items = array_merge($this->items, $this->handleArticles($articles));
     }
     parent::init();
 }
开发者ID:black-lamp,项目名称:yii2-articles,代码行数:12,代码来源:ArticlesNav.php

示例9: init

 public function init()
 {
     parent::init();
     if ($this->slug == null) {
         throw new InvalidConfigException("slug不能为空");
     }
     $this->currentAbsoluteUrl = \Yii::$app->getRequest()->getAbsoluteUrl();
     $collection = Menu::findBySlug($this->slug);
     $createCallbacks = Hook::trigger(\hass\menu\Module::EVENT_MENU_LINK_CREATE)->parameters;
     $this->items = NestedSetsTree::generateTree($collection, function ($item) use($createCallbacks) {
         list($item['label'], $item["url"]) = call_user_func($createCallbacks[$item['module']], $item['name'], $item['original']);
         $item["options"] = Serializer::unserializeToArray($item["options"]);
         return $item;
     }, 'items');
 }
开发者ID:rocketyang,项目名称:hasscms-app,代码行数:15,代码来源:MenuRenderWidget.php

示例10: init

 public function init()
 {
     parent::init();
     $this->_initOptions();
     if ($this->cache) {
         /** @var Cache $cache */
         $this->cache = Instance::ensure($this->cache, Cache::className());
         $cacheKey = [__CLASS__, $this->items];
         if (($this->items = $this->cache->get($cacheKey)) === false) {
             $this->items = ModuleEvent::trigger(self::EVENT_FETCH_ITEMS, new MenuItemsEvent(['items' => $this->items]), 'items');
             $this->cache->set($cacheKey, $this->items, $this->cacheDuration, $this->cacheDependency);
         }
     } else {
         $this->items = ModuleEvent::trigger(self::EVENT_FETCH_ITEMS, new MenuItemsEvent(['items' => $this->items]), 'items');
     }
 }
开发者ID:oakcms,项目名称:oakcms,代码行数:16,代码来源:SidebarMenu.php

示例11: init

 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     // add css class 'sidebar-menu'
     if (isset($this->options['class'])) {
         if (is_array($this->options['class']) && !in_array('sidebar-menu', $this->options['class'])) {
             $this->options['class'][] = 'sidebar-menu';
         } elseif (false === strpos($this->options['class'], 'sidebar-menu')) {
             $this->options['class'] .= ' sidebar-menu';
         }
     } else {
         $this->options['class'] = 'sidebar-menu';
     }
     // add first header item
     if (!empty($this->header)) {
         $this->items = ArrayHelper::merge([['label' => $this->header, 'options' => ['class' => 'header']]], $this->items);
     }
 }
开发者ID:memclutter,项目名称:yii2-admin-lte,代码行数:21,代码来源:SidebarMenu.php

示例12: init

    public function init()
    {
        parent::init();
        Html::addCssClass($this->options, 'iconized');
        Yii::$app->view->registerCss(<<<CSS
.iconized li {
\tbackground: no-repeat 0 50%;
}

.iconized a {
\tpadding-left: 20px;
}
CSS
, [], 'samdark/IconizedMenu');
        if ($this->useSprites) {
            $domains = $this->fetchDomains($this->items);
            $this->spriteUrl = $this->yandexBaseUrl . implode('/', $domains);
        }
    }
开发者ID:samdark,项目名称:yii2-iconized-menu-widget,代码行数:19,代码来源:Menu.php

示例13: init

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

示例14: init

 public function init()
 {
     parent::init();
     MenuAsset::register($this->getView());
     $this->activateParents = true;
 }
开发者ID:Nimther,项目名称:yii2-mmenu-widget,代码行数:6,代码来源:Menu.php

示例15: init

 public function init()
 {
     $this->items = $this->item_list();
     parent::init();
 }
开发者ID:AtuinCMS,项目名称:atuin-menus,代码行数:5,代码来源:Widget.php


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