zmm1022828887 2015-04-24 07:24:36 4423次浏览 2条评论 2 1 0
<?php
    NavBar::begin([
        'brandLabel' => 'Shi Qu',
        'brandUrl' => Yii::$app->homeUrl,
        'options' => [
            'class' => 'navbar-inverse navbar-fixed-top',
        ],
    ]);
    $menuItems = [
        ['label' => '首页', 'url' => ['/site/index']],
        ['label' => '话题', 'url' => ['/site/alltopic']],
        ['label' => '问题', 'url' => ['/site/allquestion']],
        ['label' => '文章', 'url' => ['/site/allarticle']],
    ];
    $bottomItems = [];
    $bottomItems = [
        ['label' => '<i class="icon-home"></i>&nbsp;&nbsp;我的主页', 'url' => ['/site/personal']],
        ['label' => '<i class="icon-clock"></i>&nbsp;&nbsp;任务中心', 'url' => ['/site/task']],
        ['label' => '<i class="icon-envelop"></i>&nbsp;&nbsp;私信', 'url' => ['/site/inbox']],
        ['label' => '<i class="icon-cog"></i>&nbsp;&nbsp;设置', 'url' => ['/site/setting']]];

    if (Yii::$app->user->identity->user_name == "admin")
        $bottomItems[] = ['label' => '<i class="icon-cogs"></i>&nbsp;&nbsp;管理', 'url' => ['/site/admin']];

    $bottomItems[] = ['label'=>'','options'=>['class'=>'divider']];
    $bottomItems[] = ['label' => '<i class="icon-switch"></i>&nbsp;&nbsp;退出', 'url' => ['/site/logout'], 'linkOptions' => ['data-method' => 'post']];
    if (Yii::$app->user->isGuest) {
        $rightMenuItems[] = ['label' => '注册', 'url' => ['/site/signup']];
        $rightMenuItems[] = ['label' => '登录', 'url' => ['/site/login']];
    } else {
        $rightMenuItems[] = [
            'label' => Html::img(Yii::$app->urlManager->createUrl(["site/getimage", "id" => Yii::$app->user->id, "type" => "avatar"]), ["height" => 30, "width" => 30, "style" => "margin-right:4x;"]) . Yii::$app->user->identity->user_name,
            'url' => 'javascript:;',
            'encodeLabels' => false,
            'linkOptions'=>['style'=>'padding-top:5px;padding-bottom:5px;line-height:40px;'],
            'items' => $bottomItems,
        ];
    }
    echo Nav::widget([
        'options' => ['class' => 'navbar-nav navbar-left'],
        'items' => $menuItems,
    ]);

    echo Nav::widget([
        'options' => ['class' => 'navbar-nav navbar-right'],
        'encodeLabels' => false,
        'items' => $rightMenuItems,
    ]);
    ?>
    <div class="navbar-form navbar-left">
        <div class="form-group">
            <input id="searchbox" type="text" class="form-control" placeholder="搜索问题、话题或人,,,">
        </div>
    </div>
    <?php
    NavBar::end();
?>

输入图片说明

觉得很赞
  • 评论于 2015-06-16 16:24 举报

    一点都不像, logo没有。。。搜索框可以生成的,你是手打的。。。

    1 条回复
    评论于 2016-04-14 16:48 回复

    怎么设置logo啊 搞半天不知道用什么参数

  • 评论于 2016-12-03 14:46 举报

    `NavBar::begin([

            'brandLabel' => Html::img($asset->baseUrl . '/logo.png'),
            'brandUrl' => ['default/index'],
            'options' => ['class' => 'navbar-inverse navbar-fixed-top'],
        ]);`
    

    这样子就可以把logo的位置放上图片

您需要登录后才可以评论。登录 | 立即注册