refactored NavBar and basic app navbar.

This commit is contained in:
Qiang Xue 2013-08-09 10:55:16 -04:00
parent 173374d890
commit 0d86b89cbe

View File

@ -1,4 +1,6 @@
<?php <?php
use yii\bootstrap\Nav;
use yii\bootstrap\NavBar;
use yii\helpers\Html; use yii\helpers\Html;
use yii\widgets\Menu; use yii\widgets\Menu;
use yii\widgets\Breadcrumbs; use yii\widgets\Breadcrumbs;
@ -19,24 +21,26 @@ app\config\AppAsset::register($this);
</head> </head>
<body> <body>
<?php $this->beginBody(); ?> <?php $this->beginBody(); ?>
<div class="navbar navbar-inverse navbar-fixed-top"> <?php
<div class="container"> NavBar::begin(array(
<?php echo Html::a('My Company', Yii::$app->homeUrl, array('class' => 'navbar-brand')); ?> 'brandLabel' => 'My Company',
<div class="nav-collapse collapse pull-right"> 'brandUrl' => Yii::$app->homeUrl,
<?php echo Menu::widget(array( 'options' => array(
'options' => array('class' => 'nav navbar-nav'), 'class' => 'navbar-inverse navbar-fixed-top',
'items' => array( ),
array('label' => 'Home', 'url' => array('/site/index')), ));
array('label' => 'About', 'url' => array('/site/about')), echo Menu::widget(array(
array('label' => 'Contact', 'url' => array('/site/contact')), 'options' => array('class' => 'nav navbar-nav pull-right'),
Yii::$app->user->isGuest ? 'items' => array(
array('label' => 'Login', 'url' => array('/site/login')) : array('label' => 'Home', 'url' => array('/site/index')),
array('label' => 'Logout (' . Yii::$app->user->identity->username .')' , 'url' => array('/site/logout')), array('label' => 'About', 'url' => array('/site/about')),
), array('label' => 'Contact', 'url' => array('/site/contact')),
)); ?> Yii::$app->user->isGuest ?
</div> array('label' => 'Login', 'url' => array('/site/login')) :
</div> array('label' => 'Logout (' . Yii::$app->user->identity->username .')' , 'url' => array('/site/logout')),
</div> )));
NavBar::end();
?>
<div class="container"> <div class="container">
<?php echo Breadcrumbs::widget(array( <?php echo Breadcrumbs::widget(array(