Yii2 module for menu creation., (*1)
Installation
The preferred way to install this extension is through composer., (*2)
Either run, (*3)
php composer.phar require --prefer-dist sokyrko/yii2-menu "*"
or add, (*4)
"sokyrko/yii2-menu": "*"
to the require section of your composer.json
file., (*5)
Run migration, (*6)
./yii migrate/up --migrationPath=@vendor/sokyrko/yii2-menu/migrations
Create controllers and include menu and menu-item traits. For example:, (*7)
class MenuController extends Controller
{
use MenuTrait;
}
```php
class MenuItemController extends Controller
{
use MenuItemTrait;
}, (*8)
Usage
-----
Minimal configuration:
```php
<?= MenuWidget::widget([
'menuName' => 'main_footer',
'menuWrapper' => '<ul class="bottom-nav">{items}</ul>',
]) ?>
Also you can define other settings:, (*9)
<?= MenuWidget::widget([
'menuName' => 'main_header',
'template' => function (MenuItem $current) {
return Html::tag('li', Html::a($current->title, $current->url) . '{children}', [
'class' => ($current->url == Url::to([''])) ? 'active' : '',
]);
},
'menuWrapper' => '<nav class="nav-holder"><ul id="nav">{items}</ul></nav>',
'subMenuWrapper' => '<div class="drop"><ul>{items}</ul></div>',
]) ?>