Answer the question
In order to leave comments, you need to log in
Can you tell us about UrlManager in Yii2?
Hello. I want to get a link like "directions/allergology", which will go to view.
I do this
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => [
'' => 'site/index',
'directions/<url>' => 'directions/view/',
'<controller:\w+>/<action:\w+>/' => '<controller>/<action>',
],
],
<li><a href="<?=Url::to(['/directions/view', 'url' => $items->url]); ?>"><?=$items->name?></a></li>
public function actionView($url) {
$model = Directions::find()->where(['status' => Directions::STATUS_ACTIVE])->andWhere(['url'=>$url])->one();
return $this->render('view', [
'model' => $model]);
}
'directions/<url>' => 'directions/view/'<url>,
http://site/directions/view?url=ginecology
Answer the question
In order to leave comments, you need to log in
img {border-radius:50%; height:100px; width:100px; margin-top:-50px;}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question