Answer the question
In order to leave comments, you need to log in
How to add additional content to a page that is pulled from the database?
There is a page controller:
class PageController extends AppController
{
public function actionView($alias)
{
$page = Page::find()->where(['alias' => $alias])->one();
if(empty($page)){
throw new HttpException(404, 'Страница не найдена.');
}
return $this->render('view', compact(['page']));
}
}
Answer the question
In order to leave comments, you need to log in
Good evening.
Alternatively, you can do this:
class PageController extends AppController
{
public function actionView($alias)
{
$page = Page::find()->where(['alias' => $alias])->one();
if(empty($page)){
throw new HttpException(404, 'Страница не найдена.');
}
$contact = new ContactForm();
return $this->render('view', ['page' => $page, 'contact' => $contact]);
}
}
$page = Page::find()->where(['alias' => $alias])->one();
if(empty($page)){
throw new HttpException(404, 'Страница не найдена.');
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question