tyan tyan - 3 years ago 346
PHP Question

Yii2 controller render() function only render the layouts/main?

In my SiteController under namespace repo/controllers call

return $this->render('index');


it only render the /views/layouts/main.php but I need to render the /views/site/index.php alone with the layouts files.

If I change into

return $this->renderPartial('index');


it renders the /views/site/index.php without problem. So what's the problem with the render() function??

Answer Source

Please, make sure you didn't missed <?= $content ?> at your layouts/main.php. That should render your content

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download