Render view Yii2

Fuad Ibrahimov picture Fuad Ibrahimov · May 19, 2015 · Viewed 23.6k times · Source

How do you render a view file in the profile module's index view file. I tried this:

<?=$this->render('/product/product/_search')?>

This is the error I get:

The view file does not exist: C:\OpenServer\domains\zuppermart\frontend\modules\profile\views\product/product/_search.php`

I also tried <?=$this->render('//product/product/_search')?>

And I get this error:

The view file does not exist: C:\OpenServer\domains\zuppermart\frontend\modules\profile\views\profile\modules//product/product/_search.php

Answer

arogachev picture arogachev · May 19, 2015

According to given paths, it should be like this (absolute path specified via alias):

<?= $this->render('@frontend/modules/product/_search') ?>

But note that you are trying to render view from another module, I think it's better to create widget instead.

Official docs: