D. Milk
D. Milk

Reputation: 75

Showing Active Items w/ Yii2 Sidenav

I'm wondering if https://github.com/kartik-v/yii2-widget-sidenav is capable of showing a page that is not the 'active item' as active. An example being I have my menu item set at 'active' => ($item == 'site/home'), but I would like to essentially have site/home2 show the same menu item as active. Treating it as a child page within the same controller.

Thanks!

Upvotes: 0

Views: 119

Answers (1)

Vinay Sheoran
Vinay Sheoran

Reputation: 528

Yes, you can specify which menu item should be active on any particular URL.

For example:

['label' => 'Home', 'icon' => 'home', 'url' => Url::to(['/site/home', 'type'=>$type]), 'active' => ($currentPage == 'page1')],

here 'active' specify the codition on which this menu should be active.

so in your case:

'active' => ($item == 'site/home' || $item == 'site/home2')

Upvotes: 1

Related Questions