sidebar in yii2

Hy guys,

Can you someone pls give a advice how can I make a sidebar(left sidebar menu) in my app ? Do I have to change main.php in layouts of view or I am totaly uotside of solution ?

Thanks for any advice :) I want my own Sidebar, but I do not know how we can divide the page into two parts …




<div class="wrap">

    <div id="sidebar">


    </div>

    <div id="content">

        <?php

        NavBar::begin([

            'brandLabel' => 'App',

            'brandUrl' => Yii::$app->homeUrl,

            'options' => [

                'class' => 'navbar-inverse navbar-fixed-top',

            ],

        ]);

        echo Nav::widget([

            'options' => ['class' => 'navbar-nav navbar-right'],

            'items' => [

                ['label' => 'Feeds', 'url' => ['feed/index']],

                ['label' => 'Home', 'url' => ['/site/index']],

                ['label' => 'Contact', 'url' => ['/site/contact']],

                Yii::$app->user->isGuest ? (

                    ['label' => 'Login', 'url' => ['/site/login']]

                ) : (

                    '<li>'

                    . Html::beginForm(['/site/logout'], 'post')

                    . Html::submitButton(

                        'Logout (' . Yii::$app->user->identity->username . ')',

                        ['class' => 'btn btn-link logout']

                    )

                    . Html::endForm()

                    . '</li>'

                )

            ],

        ]);

        NavBar::end();

        ?>


        <div class="container">

            <?= Breadcrumbs::widget([

                'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],

            ]) ?>

            <?= $content ?>

        </div>

    </div>

</div>



Can I start like this ? in main.php from views/layouts

Maybe this can give you some inspiration:

http://getbootstrap.com/css/#grid

Hi, in addition to Patrick Jones[color=#1D3652][size=2] [/size][/color]

try this:

1-add namespace:


<?php 

use yii\bootstrap\NavBar;

?>

2-this code in the sidebar id:


<?= Nav::widget([

	'options' => ['class' => 'nav-pills nav-stacked'],

 		'items' =>  [

        	['label' => 'Link', 'url' => ['/link/to']],

        	['label' => 'Link', 'url' => ['/link/to']],

        	['label' => 'Link', 'url' => ['/link/to']],

    	],

]); ?>

Doc yii2