I use Navbar in Yii, I generate for it in a cycle several links with a parameter:

for ($i = 1; $i < $names[$i]; $i++) { $labels[]= ['label' => $i, 'url' => Url::toRoute(['/site/index', 'id' => $i])]; } 

The menu is built, but when you click on links with different parameters, these links are not highlighted as active. The home link that corresponds to / site / index remains active.

I suggested that this is due to the fact that I used Url :: toRoute, instead of the usual

 'url' => ['маршрут'] 

However, I did not find in the documentation how to write parameters in this notation. Also, I did not find a clear description of link activity management there: http://www.yiiframework.com/doc-2.0/yii-bootstrap-nav.html

    1 answer 1

    In the NavBar widget, you can set the parameter in the link as follows:

     'url' => [ '/site/index', 'id' => $id ] 

    And yes, with such a record the highlighting of the active link will work.