예제 #1
0
		<div class="header-desktop clearfix">
			<div class="colf12x4">
				<?php 
    echo Html::a("<img class='logo' src='" . Yii::getAlias('@images') . "/logo.png'>", ['/cmgcore/user/home'], null);
    ?>
			</div>
			<div class="colf12x8">
			<?php 
    echo BasicNav::widget(['options' => ['class' => 'nav-main'], 'items' => $privateMenuItems]);
    ?>
			</div>
		</div>
		<div class="header-mobile clearfix">
			<div id="btn-mobile-menu"> 
				<span class="fa fa-3x fa-bars"></span>
			</div>
			<?php 
    echo Html::a("<img class='logo' src='" . Yii::getAlias('@images') . "/logo.png'>", ['/cmgcore/user/home'], null);
    ?>
			<?php 
    echo BasicNav::widget(['options' => ['class' => 'nav-main', 'id' => 'nav-mobile'], 'items' => $privateMenuItemsMobile]);
    ?>
		</div>
		<div id="box-settings" class='popout-header'>
			<?php 
    echo BasicNav::widget(['options' => ['class' => 'nav-settings'], 'items' => $settingsMenuItems]);
    ?>
		</div>
	</header>
<?php 
}
예제 #2
0
 public function renderItems()
 {
     $user = Yii::$app->user->getIdentity();
     $menu = MenuService::findBySlug($this->slug);
     $pageSlug = Yii::$app->request->get('slug');
     if (isset($menu) && $menu->active) {
         $pageLinks = MenuService::getPageLinks($menu, true);
         $pageLinks = array_keys($pageLinks);
         $pages = PageService::getMenuPages($pageLinks, true);
         $menuItems = $menu->generateObjectFromJson(true);
         $menuItems = $menuItems->links;
         $absoluteUrl = Yii::$app->request->absoluteUrl;
         foreach ($menuItems as $menuItem) {
             if (strcmp($menuItem['type'], CmsGlobal::TYPE_PAGE) == 0) {
                 $link = new PageLink($menuItem);
                 $item = null;
                 $address = null;
                 if (isset($pages[$link->pageId])) {
                     $page = $pages[$link->pageId];
                     if ($page->isPublic() || isset($user)) {
                         if (strcmp($page->slug, 'home') == 0) {
                             $address = Url::toRoute(["/"]);
                         } else {
                             $address = Url::toRoute(["/{$page->slug}"]);
                         }
                         $item = ['url' => $address, 'label' => $page->name, 'icon' => $page->icon];
                         if (isset($link->options)) {
                             $item['options'] = json_decode($link->options);
                         }
                         if (isset($pageSlug) && strcmp($pageSlug, $page->slug) == 0) {
                             $item['options'] = ['class' => 'active'];
                         }
                         $this->items[] = $item;
                     }
                 }
             } else {
                 if (strcmp($menuItem['type'], CmsGlobal::TYPE_LINK) == 0) {
                     $link = new Link($menuItem);
                     $item = null;
                     $address = null;
                     if (strlen($link->label) > 0) {
                         if ($link->isPublic() || isset($user)) {
                             if ($link->relative) {
                                 // Clean URL if first character is slash
                                 if (substr($link->address, 0, 1) == "/") {
                                     $link->address = substr($link->address, 1);
                                 }
                                 $address = Url::toRoute(["/{$link->address}"], true);
                             } else {
                                 $address = $link->address;
                             }
                             $item = ['url' => $address, 'label' => $link->label, 'icon' => $link->icon];
                             if (isset($link->options)) {
                                 $item['options'] = json_decode($link->options);
                             }
                             if (strcmp($address, $absoluteUrl) == 0) {
                                 $item['options'] = ['class' => 'active'];
                             }
                             $this->items[] = $item;
                         }
                     }
                 }
             }
         }
     }
     return parent::renderItems();
 }