My task is simple. I have to render frontend view from backend controller. What i've done so far is to create urlManagerFrontendView
path in my main.php
:
'urlManagerFrontendView' => [
'class' => 'yii\web\urlManager',
'baseUrl' => $_SERVER['DOCUMENT_ROOT'] . '/frontend/view/',
'enablePrettyUrl' => true,
'showScriptName' => false,
],
This is how i am trying to render it(from the backend):
return $this->render(''.Yii::$app->urlManagerFrontendView->baseUrl.'page/product', [
'model' => $product,
'product_rel' => $product_rel,
'thispage' => $thispage,
]);
But what i get is an error:
The view file does not exist: /home/projects/tashev-online/htdocs/backend/views/home/projects/tashev-online/htdocs/frontend/viewpage/product.php
Obviously i didn't create it right :) So can you guys help my with my path? What is the right way to reach the frontend? Thank you in advance!
You don't have to do anything with UrlManager in this case. Simply call the view using relative path (like this or similar):
return $this->render('../../../frontend/views/page/product', ...