Any content enclosed between the [[begin()]] and [[end()]] calls of NavBar is treated as the content of the navbar. You may use widgets such as Nav or Menu to build up such content. For example, php use yii\bootstrap\NavBar; use yii\bootstrap\Nav; NavBar::begin(['brandLabel' => 'NavBar Test']); echo Nav::widget([ 'items' => [ ['label' => 'Home', 'url' => ['/site/index']], ['label' => 'About', 'url' => ['/site/about']], ], 'options' => ['class' => 'navbar-nav'], ]); NavBar::end();
See also: http://getbootstrap.com/components/#navbar
Since: 2.0
Author: Antonio Ramirez (amigo.cobos@gmail.com)
Author: Alexander Kochetov (creocoder@gmail.com)
Inheritance: extends yii\bootstrap\Widget
示例#1
2
文件: Tor.php 项目: mark38/yii2-tor
 public function run()
 {
     NavBar::begin(['brandLabel' => false, 'options' => ['class' => 'tor-nav']]);
     echo Html::tag('div', $this->torMenu(), ['class' => 'container']);
     NavBar::end();
     $view = $this->view;
     NavAsset::register($view);
 }
示例#2
1
文件: Top.php 项目: mark38/yii2-tor
 public function run()
 {
     NavBar::begin(['brandLabel' => false, 'options' => ['class' => 'top-nav']]);
     echo NavX::widget(['items' => $this->topMenu(), 'options' => ['class' => 'nav navbar-nav navbar-left nav-pills main-nav'], 'encodeLabels' => false]);
     echo NavX::widget(['items' => $this->accountMenu(), 'options' => ['class' => 'nav navbar-nav navbar-right nav-pills account-top-nav'], 'encodeLabels' => false]);
     NavBar::end();
     $view = $this->view;
     NavAsset::register($view);
 }
示例#3
1
 public function getMenu()
 {
     $isAdmin = !Yii::$app->user->isGuest ? Yii::$app->user->identity->can('editor') : false;
     $canAdmin = !Yii::$app->user->isGuest ? Yii::$app->user->identity->can('editor') : false;
     $networksVisible = count(Yii::$app->authClientCollection->clients) > 0;
     $menuItems = [['label' => 'Home', 'url' => ['/site/index']], ['label' => 'About', 'url' => ['/site/about']], ['label' => 'Contact', 'url' => ['/site/contact']]];
     if (Yii::$app->user->isGuest) {
         $menuItems[] = ['label' => Yii::t('user', 'Sign up'), 'url' => ['/user/registration/register']];
         $menuItems[] = ['label' => Yii::t('user', 'Sign in'), 'url' => ['/user/security/login']];
     } else {
         $menuItems['user'] = ['label' => $isAdmin ? Yii::$app->user->identity->profile->fullname . ' (admin)' : Yii::$app->user->identity->profile->fullname, 'items' => [['label' => Yii::t('user', 'Profile'), 'url' => ['/user/settings/profile']], ['label' => Yii::t('user', 'Account'), 'url' => ['/user/settings/account']], ['label' => Yii::t('user', 'Networks'), 'url' => ['/user/settings/networks'], 'visible' => $networksVisible], '<li class="divider"></li>', ['label' => Yii::t('user', 'Logout'), 'url' => ['/user/security/logout'], 'linkOptions' => ['data-method' => 'post']]]];
     }
     if ($canAdmin) {
         $menuItems['user']['items'][] = '<li class="divider"></li>';
         $menuItems['user']['items'][] = ['label' => Yii::t('user', 'Admin Panel'), 'url' => Yii::$app->urlManagerBackEnd->createUrl('')];
     }
     NavBar::begin(['brandLabel' => Yii::$app->params['companyName'], 'brandUrl' => Yii::$app->homeUrl, 'options' => ['class' => 'navbar-inverse navbar-fixed-top']]);
     echo Nav::widget(['options' => ['class' => 'navbar-nav navbar-right'], 'items' => $menuItems]);
     NavBar::end();
 }
示例#4
0
文件: Module.php 项目: ochiem/app-cms
 /**
  * Renders mini-toolbar at the end of page body.
  *
  * @param \yii\base\Event $event
  */
 public function renderToolbar($event)
 {
     /* @var $view View */
     /* @var $urlManagerBack \yii\web\UrlManager */
     $urlManagerBack = Yii::$app->urlManagerBack;
     $view = $event->sender;
     $view->registerCss($view->renderPhpFile(__DIR__ . '/assets/toolbar.min.css'));
     NavBar::begin(['id' => 'wd-frontend-toolbar', 'brandLabel' => Html::img('@web/img/logo-mini.png'), 'brandUrl' => $urlManagerBack->baseUrl, 'innerContainerOptions' => ['class' => 'container-fluid'], 'options' => ['class' => 'navbar navbar-inverse navbar-fixed-top']]);
     echo Nav::widget(['encodeLabels' => false, 'options' => ['class' => 'navbar-nav'], 'items' => [['label' => '<span aria-hidden="true" class="glyphicon glyphicon-dashboard"></span> ' . Option::get('sitetitle'), 'items' => [['label' => Yii::t('toolbar', 'Dashboard'), 'url' => $urlManagerBack->baseUrl], ['label' => Yii::t('toolbar', 'Themes'), 'url' => $urlManagerBack->createUrl(['/theme']), 'visible' => Yii::$app->user->can('administrator')], ['label' => Yii::t('toolbar', 'Menus'), 'url' => $urlManagerBack->createUrl(['/menu']), 'visible' => Yii::$app->user->can('administrator')], ['label' => Yii::t('toolbar', 'Modules'), 'url' => $urlManagerBack->createUrl(['/module']), 'visible' => Yii::$app->user->can('administrator')], ['label' => Yii::t('toolbar', 'Widgets'), 'url' => $urlManagerBack->createUrl(['/widget']), 'visible' => Yii::$app->user->can('administrator')]]], ['label' => '<span aria-hidden="true" class="glyphicon glyphicon-plus"></span> ' . Yii::t('toolbar', 'New'), 'items' => $this->getAddNewMenu() ? $this->getAddNewMenu() : null]]]);
     echo Nav::widget(['encodeLabels' => false, 'options' => ['class' => 'navbar-nav navbar-right'], 'items' => [['label' => '<span aria-hidden="true" class="glyphicon glyphicon-user"></span> ' . Yii::$app->user->identity->username, 'items' => [['label' => 'Profile', 'url' => $urlManagerBack->createUrl(['/user/profile'])], ['label' => 'Logout', 'url' => ['/site/logout'], 'linkOptions' => ['data-method' => 'post']]]]]]);
     NavBar::end();
 }
示例#5
0
文件: admin.php 项目: ivphpan/iris
?>
</title>
    <?php 
$this->head();
?>
</head>
<body>
<?php 
$this->beginBody();
?>

<div class="wrap">
    <?php 
NavBar::begin(['brandLabel' => \Yii::$app->name, 'brandUrl' => Yii::$app->homeUrl, 'options' => ['class' => 'navbar-inverse']]);
echo Nav::widget(['options' => ['class' => 'navbar-nav navbar-right'], 'items' => [['label' => 'События', 'items' => [['label' => 'Категории', 'url' => ['/article/category']], ['label' => 'Список', 'url' => ['/article/events']]]], ['label' => 'Каталог', 'items' => [['url' => ['/catalog/category'], 'label' => 'Категории'], ['url' => ['/catalog/brand'], 'label' => 'Бренды']]], ['label' => 'Настройки', 'url' => ['/settings/settings']], Yii::$app->user->isGuest ? ['label' => 'Login', 'url' => ['/site/login']] : ['label' => 'Logout (' . Yii::$app->user->identity->username . ')', 'url' => ['/site/logout'], 'linkOptions' => ['data-method' => 'post']]]]);
NavBar::end();
?>

    <div class="container">
        <?php 
echo Breadcrumbs::widget(['links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : []]);
?>
        <?php 
echo $content;
?>
    </div>
</div>

<footer class="footer">
    <div class="container">
        <p class="pull-left">&copy; <?php 
示例#6
0
$this->head();
?>
</head>
<body>
<?php 
$this->beginBody();
\yii\bootstrap\NavBar::begin(['brandLabel' => Yii::$app->siteName, 'brandUrl' => Yii::$app->homeUrl, 'options' => ['class' => 'navbar-inverse navbar-fixed-top']]);
$items = [['label' => '<i class="glyphicon glyphicon-home"></i> ' . Yii::t('gromver.platform', 'Home'), 'url' => Yii::$app->homeUrl]];
if (Yii::$app->user->can('administrate')) {
    $items[] = ['label' => '<i class="glyphicon glyphicon-cog"></i> ' . Yii::t('gromver.platform', 'Admin Panel'), 'url' => ['/main/backend/default/index']];
}
if (Yii::$app->request->referrer) {
    $items[] = ['label' => '<i class="glyphicon glyphicon-step-backward"></i> ' . Yii::t('gromver.platform', 'Back'), 'url' => Yii::$app->request->referrer];
}
echo \yii\bootstrap\Nav::widget(['options' => ['class' => 'navbar-nav navbar-right'], 'encodeLabels' => false, 'items' => $items]);
\yii\bootstrap\NavBar::end();
?>

<div class="wrap">
    <div class="container">
        <?php 
echo \yii\widgets\Breadcrumbs::widget(['links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : []]);
?>
        <?php 
foreach (Yii::$app->session->getAllFlashes() as $type => $body) {
    echo \kartik\widgets\Alert::widget(['type' => $type, 'body' => $body]);
}
?>
        <?php 
echo $content;
?>
?>
    <title><?php 
echo Html::encode($this->title);
?>
</title>
    <?php 
$this->head();
?>
</head>
<body>
    <?php 
$this->beginBody();
?>
    <div class="wrap">
        <?php 
NavBar::begin(['brandLabel' => 'Woo Soft', 'brandUrl' => Yii::$app->homeUrl, 'options' => ['class' => 'navbar-inverse navbar-fixed-top']]);
?>











                <div class="main-content">
                    <?php 
echo $content;
 public function actionMenu()
 {
     NavBar::begin(['brandLabel' => Yii::$app->name, 'brandUrl' => Yii::$app->homeUrl, 'options' => ['class' => 'navbar-inverse', 'style' => 'z-index: 9999;']]);
     echo MenuWidget::widget(['direction' => 'left', 'options' => ['class' => 'navbar-nav navbar-right']]);
     NavBar::end();
 }
示例#9
-1
文件: NavBar.php 项目: semnt/tp01
 public function init()
 {
     if ($this->brandGlyphicon) {
         $this->brandLabel = Html::glyphicon($this->brandGlyphicon) . $this->brandLabel;
     }
     parent::init();
 }