仿造社区生成header部分代码 [ 2.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> 我的主页', 'url' => ['/site/personal']],
['label' => '<i class="icon-clock"></i> 任务中心', 'url' => ['/site/task']],
['label' => '<i class="icon-envelop"></i> 私信', 'url' => ['/site/inbox']],
['label' => '<i class="icon-cog"></i> 设置', 'url' => ['/site/setting']]];
if (Yii::$app->user->identity->user_name == "admin")
$bottomItems[] = ['label' => '<i class="icon-cogs"></i> 管理', 'url' => ['/site/admin']];
$bottomItems[] = ['label'=>'','options'=>['class'=>'divider']];
$bottomItems[] = ['label' => '<i class="icon-switch"></i> 退出', '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();
?>
zmm1022828887 北京
注册时间:2014-12-16
最后登录:2024-08-14
在线时长:64小时12分
最后登录:2024-08-14
在线时长:64小时12分
- 粉丝16
- 金钱6875
- 威望20
- 积分7715
共 2 条评论
一点都不像, logo没有。。。搜索框可以生成的,你是手打的。。。
怎么设置logo啊 搞半天不知道用什么参数
`NavBar::begin([
'brandLabel' => Html::img($asset->baseUrl . '/logo.png'), 'brandUrl' => ['default/index'], 'options' => ['class' => 'navbar-inverse navbar-fixed-top'], ]);`
这样子就可以把logo的位置放上图片