7

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

Ryan Wheale
  • 26,022
  • 8
  • 76
  • 96
Fuad Ibrahimov
  • 492
  • 2
  • 10
  • 21

3 Answers3

16

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:

arogachev
  • 33,150
  • 7
  • 114
  • 117
1

in yii2, we can use render like this :

$this->render('contact',['model'=>$model]);

and render partial:

Yii::$app->controller->renderPartial('myview');

Mahmut Aydın
  • 831
  • 13
  • 21
0

A simple solution to this kind views error is to use views base path i.e by using @app/views/: <?=$this->render('@app/views/product/product/_search')?>

Farid Abbas
  • 294
  • 4
  • 5