/** * @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); } } } }
/** * 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(); } }
/** * 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'; } }
/** * 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'); }
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'); }
/** * 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']; }
/** * */ 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'); } } }
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(); }
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'); }
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'); } }
/** * @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); } }
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); } }
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'); }
public function init() { parent::init(); MenuAsset::register($this->getView()); $this->activateParents = true; }
public function init() { $this->items = $this->item_list(); parent::init(); }
public function init() { $_role = Auction::userRole(); if ($_role == DatabaseHelper::COMPANY_ADMIN) { $this->items = [ ['label' => '<i class="fa fa-dashboard fa-fw"></i>Dashboard', 'url' => Auction::createUrl('company/info')], [ 'template' => '<a class="active" href="#"><i class="fa fa-wrench fa-fw"></i>Auctions<span class="fa arrow"></span></a>', 'items' => [ ['label' => '<i class="fa fa-play-circle-o fa-fw"></i>List Auctions', 'url' => Auction::createUrl('company/auction')], ['label' => '<i class="fa fa-github-square fa-fw"></i>Add Auction', 'url' => Auction::createUrl('company/auction/create')], ], ], [ 'template' => '<a class="active" href="#"><i class="fa fa-wrench fa-fw"></i>Users<span class="fa arrow"></span></a>', 'items' => [ ['label' => '<i class="fa fa-play-circle-o fa-fw"></i>List Company Users', 'url' => Auction::createUrl('company/user')], ['label' => '<i class="fa fa-github-square fa-fw"></i>Dealers', 'url' => Auction::createUrl('company/dealer')], ], ], [ 'template' => '<a class="active" href="#"><i class="fa fa-wrench fa-fw"></i>Auction Lots<span class="fa arrow"></span></a>', 'items' => [ ['label' => '<i class="fa fa-play-circle-o fa-fw"></i>Lots', 'url' => Auction::createUrl('company/lots')], ['label' => '<i class="fa fa-play-circle-o fa-fw"></i>Add Products In Lot', 'url' => Auction::createUrl('company/lot-product')], ], ], [ 'template' => '<a class="active" href="#"><i class="fa fa-wrench fa-fw"></i>Products<span class="fa arrow"></span></a>', 'items' => [ ['label' => '<i class="fa fa-play-circle-o fa-fw"></i>List Products', 'url' => Auction::createUrl('company/product')], ['label' => '<i class="fa fa-play-circle-o fa-fw"></i>Upload CSV', 'url' => Auction::createUrl('company/upload-csv')], ['label' => '<i class="fa fa-play-circle-o fa-fw"></i>Create Product Cofig', 'url' => Auction::createUrl('company/product-config')], ], ], [ 'template' => '<a class="active" href="#"><i class="fa fa-wrench fa-fw"></i>Setting<span class="fa arrow"></span></a>', 'items' => [ ['label' => '<i class="fa fa-play-circle-o fa-fw"></i>Update Info', 'url' => Auction::createUrl('company/edit')], ], ], ]; } elseif ($_role == DatabaseHelper::DEALER) { $this->items = [ ['label' => '<i class="fa fa-dashboard fa-fw"></i>Dashboard', 'url' => Auction::createUrl('dealer/profile')], ['label' => '<i class="fa fa-dashboard fa-fw"></i>Auctions', 'url' => Auction::createUrl('dealer/auction')], ['label' => '<i class="fa fa-dashboard fa-fw"></i>Companies', 'url' => Auction::createUrl('dealer/company')], ['label' => '<i class="fa fa-dashboard fa-fw"></i>Payment', 'url' => Auction::createUrl('dealer/payment')], [ 'template' => '<a class="active" href="#"><i class="fa fa-wrench fa-fw"></i>Setting<span class="fa arrow"></span></a>', 'items' => [ ['label' => '<i class="fa fa-play-circle-o fa-fw"></i>Update Info', 'url' => Auction::createUrl('dealer/edit-profile')], ], ], ]; } $this->items[] = ['label' => '<i class="fa fa-sign-out fa-fw"></i>Sign Out', 'url' => Auction::createUrl('site/logout')]; parent::init(); }
public function init() { parent::init(); SideNavAsset::register($this->getView()); $this->markTopItems(); Html::addCssClass($this->options, ''); }
public function init() { parent::init(); $this->linkTemplate = '<a href="{url}" title="{label}"><i class="fa fa-{icon}"></i><span>{label}</span></a>'; $this->submenuTemplate = "\n<ul class=\"treeview-menu\">\n{items}\n</ul>\n"; }
public function init() { parent::init(); $defaults = ['tag' => 'div', 'id' => $this->getId()]; $this->options = ArrayHelper::merge($defaults, $this->options); }
public function init() { parent::init(); $this->loadMenu(); }
public function init() { parent::init(); // next init }
/** * @inheritdoc */ public function init() { Html::addCssClass($this->options, 'sidebar-menu'); parent::init(); }
public function init() { parent::init(); $this->ensureVisibility($this->items); }
public function init() { parent::init(); $this->_initOptions(); }