Answer the question
In order to leave comments, you need to log in
Nested Yii2 pages?
Hello. I'm making a small blog in Yii2. I've been trying to make nested pages for a long time. Does not work.
Here is what I have:
urlManager router: 'page/<url:[\w_\/-]+>' => 'page/view',
Controller:
public function actionView($url)
{
$explode = explode('/',$url);
$post = Page::find()
->with(['page'])
->where([
'page.url' => $url,
])
->one();
if (!$post) {
throw new NotFoundHttpException(Yii::t('page', 'The requested article does not exist.'));
}
return $this->render('view', [
'post' => $post,
]);
}
'page/<url:\w+>' => 'page/view',
'page/<url>/<url2:\w+>' => 'page/view',
'page/<url>/<url2>/<url3:\w+>' => 'page/view',
<code>'page/<url:[\w_\/-]+>' => 'page/view',</code>
Answer the question
In order to leave comments, you need to log in
Good time of the day! You need to write your handler: www.yiiframework.com/doc-2.0/guide-runtime-routing.html here at the very end there is an example of a handler class.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question