Пример #1
0
echo $directoryAsset;
?>
/img/user2-160x160.jpg" class="img-circle" alt="User Image"/>
            </div>
            <div class="pull-left info">
                <p>Alexander Pierce</p>

                <a href="#"><i class="fa fa-circle text-success"></i> Online</a>
            </div>
        </div>

        <!-- search form -->
        <form action="#" method="get" class="sidebar-form">
            <div class="input-group">
                <input type="text" name="q" class="form-control" placeholder="Search..."/>
              <span class="input-group-btn">
                <button type='submit' name='search' id='search-btn' class="btn btn-flat"><i class="fa fa-search"></i>
                </button>
              </span>
            </div>
        </form>
        <!-- /.search form -->

        <?php 
echo ptiuma\widgets\Menu::widget(['options' => ['class' => 'sidebar-menu'], 'items' => [['label' => 'Menu Yii2', 'options' => ['class' => 'header']], ['label' => 'Gii', 'icon' => 'fa fa-file-code-o', 'url' => ['/gii']], ['label' => 'Debug', 'icon' => 'fa fa-dashboard', 'url' => ['/debug']], ['label' => 'Login', 'url' => ['site/login'], 'visible' => Yii::$app->user->isGuest], ['label' => 'Same tools', 'icon' => 'fa fa-share', 'url' => '#', 'items' => [['label' => 'Gii', 'icon' => 'fa fa-file-code-o', 'url' => ['/gii']], ['label' => 'Debug', 'icon' => 'fa fa-dashboard', 'url' => ['/debug']], ['label' => 'Level One', 'icon' => 'fa fa-circle-o', 'url' => '#', 'items' => [['label' => 'Level Two', 'icon' => 'fa fa-circle-o', 'url' => '#'], ['label' => 'Level Two', 'icon' => 'fa fa-circle-o', 'url' => '#', 'items' => [['label' => 'Level Three', 'icon' => 'fa fa-circle-o', 'url' => '#'], ['label' => 'Level Three', 'icon' => 'fa fa-circle-o', 'url' => '#']]]]]]]]]);
?>

    </section>

</aside>
Пример #2
0

<?php 
// prepare menu items, get all modules
$menuItems = [];
$favouriteMenuItems[] = ['label' => 'MAIN NAVIGATION', 'options' => ['class' => 'header']];
$developerMenuItems = [];
foreach (\ptiuma\helpers\Metadata::getModules() as $name => $module) {
    $role = $name;
    $defaultItem = ['icon' => 'fa fa-cube', 'label' => $name, 'url' => ['/' . $name], 'visible' => Yii::$app->user->can($role) || Yii::$app->user->identity && Yii::$app->user->identity->isAdmin, 'items' => []];
    // check for module configuration and assign to favourites
    $moduleConfigItem = is_object($module) ? isset($module->params['menuItems']) ? $module->params['menuItems'] : [] : (isset($module['params']['menuItems']) ? $module['params']['menuItems'] : []);
    switch (true) {
        case !empty($moduleConfigItem):
            $moduleConfigItem = array_merge($defaultItem, $moduleConfigItem);
            $moduleConfigItem['visible'] = \ptiuma\helpers\RouteAccess::can($moduleConfigItem['url']);
            $favouriteMenuItems[] = $moduleConfigItem;
            continue 2;
            break;
        default:
            $defaultItem['icon'] = 'fa fa-circle-o';
            $developerMenuItems[] = $defaultItem;
            break;
    }
}
// create developer menu, when user is admin
if (Yii::$app->user->identity && Yii::$app->user->identity->isAdmin) {
    $menuItems[] = ['url' => '#', 'icon' => 'fa fa-cog', 'label' => 'Developer', 'items' => $developerMenuItems, 'options' => ['class' => 'treeview'], 'visible' => Yii::$app->user->identity->isAdmin];
}
echo ptiuma\widgets\Menu::widget(['options' => ['class' => 'sidebar-menu'], 'items' => \yii\helpers\ArrayHelper::merge($favouriteMenuItems, $menuItems)]);