PHP code example of nedarta / yii2-extended-navbar
1. Go to this page and download the library: Download nedarta/yii2-extended-navbar library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
nedarta / yii2-extended-navbar example snippets
use nedarta\navbar\ExtendedNavBar;
use yii\bootstrap5\Nav;
ExtendedNavBar::begin([
'brandLabel' => 'My Company',
'brandUrl' => Yii::$app->homeUrl,
'options' => [
'class' => 'navbar-expand-lg navbar-light bg-light',
],
'externalItems' => Nav::widget([
'options' => ['class' => 'navbar-nav ms-auto d-flex flex-row gap-2 me-3'],
'items' => [
['label' => 'EN', 'url' => ['/site/language', 'lang' => 'en']],
['label' => 'LV', 'url' => ['/site/language', 'lang' => 'lv']],
],
]),
]);
echo Nav::widget([
'options' => ['class' => 'navbar-nav me-auto mb-2 mb-lg-0'],
'items' => [
['label' => 'Home', 'url' => ['/site/index']],
['label' => 'About', 'url' => ['/site/about']],
['label' => 'Contact', 'url' => ['/site/contact']],
],
]);
ExtendedNavBar::end();
use nedarta\navbar\ExtendedNavBar;
use yii\bootstrap5\Nav;
ExtendedNavBar::begin([
'externalItemsPosition' => 'after',
'highlightActiveItems' => true,
'externalItemsArray' => [
'options' => ['class' => 'navbar-nav ms-auto d-flex flex-row gap-2 me-3'],
'items' => [
['label' => 'Profile', 'url' => ['/user/profile']],
['label' => 'Settings', 'url' => ['/user/settings']],
],
],
]);
echo Nav::widget([
'options' => ['class' => 'navbar-nav me-auto'],
'items' => [
['label' => 'Home', 'url' => ['/site/index']],
],
]);
ExtendedNavBar::end();
['items' => [/* your items */]]