Answer the question
In order to leave comments, you need to log in
How to pass GET parameter to url in Yii2 in Widget Nav?
Just started learning Yii. I work with the Nav widget following the example from the interactive course by Evgeny Tkachenko . I pass the url parameter to the Nav (/site/about for example). Things are good.
The lesson "Views and Templates" suggests using yii\web\ViewAction
, which allows displaying simple pages without separate ones action
in the controller, but simply /site/page&view=about
displaying the contents of the /fronted/views/site/pages/about.php
.
How to pass this link as url
to Nav::widget
?
Example:
$menuItems = [
['label' => 'Главная', 'url' => ['/site/index']],
['label' => 'О нас', 'url' => ['/site/page&view=about'], 'encode' => 'false'],
];
echo Nav::widget([
'options' => ['class' => 'navbar-nav navbar-right'],
'items' => $menuItems,
]);
/site/page&view=about
- escaped when displaying the widget. Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question