'<url:[\w\-]+>' => '/site/page',
public function actionPage($url)
{
$page = Pages::findOne(['url' => $url]);
if ($page == NULL)
throw new NotFoundHttpException('Запрашиваемая страница не найдена.');
$page->updateCounters(['views_total' => 1]);
if ($page->children && $page->is_section) {
$query = Pages::find()->where(['p_id' => $page->id]);
$countQuery = clone $query;
$pages = new Pagination(['totalCount' => $countQuery->count(), 'pageSize' => 10]);
$pages->pageSizeParam = false;
$relatedPages = $query->offset($pages->offset)
->limit(35)
->orderBy(DATE_DESC)
->all();
return $this->render('directory', [
'page' => $page,
'relatedPages' => $relatedPages,
'pages' => $pages
]);
} elseif (!$page->children && !$page->is_section) {
Yii::$app->opengraph->set([
'title' => $page->title,
'description' => $page->seo_description,
'image' => $page->getImagePath(),
'locale' => 'ru-RU',
]);
return $this->render('page', ['page' => $page]);
} elseif ($page->is_section) {
return $this->render('section', ['page' => $page]);
}
}