The site has a folder backend and frontend , which have their own controllers, models, types. Inside the frontend folder there is a CRM module, inside of which there are also controllers, view models.

I need the CRM module to use the layout and view from the frontend folder, not its own.

I wrote in the file module.php :

 class Module extends \yii\base\Module { public $layoutPath = '@app/views/layouts'; public $layout = 'main'; ... } 

I get an error:

yii \ base \ ViewNotFoundException: The view file doesn’t exist: D: \ OSPanel \ domains \ Etest.com \ frontend \ modules \ crm \ views \ layouts \ main.php

Dances with a tambourine around $layoutPath and $layout , which consisted in prescribing relative, absolute urls, aliases, have no effect. I get the same error. In this case, $layoutPath does not really affect the situation.

what I understood from errors is that the topmost level for a CRM module is the modules folder and it cannot look into the fronend/views/latout

Question: how can my module get access to the general template?

  • If you use two slashes in the render, then the view will be loaded from frontend/views , it is quite possible that it works the same way with templates. <? = $ this-> render ('// blocks / _button')?> In this case, use frontend/views/blocks/_button - fedornabilkin
  • Yes, this thing helps! Two slashes make it possible to look above - Oughtem

1 answer 1

Try this:

 public $layout = '@frontend/views/layouts/main'; 
  • no, it looks in the folders under the folder D: \ OSPanel \ domains \ Etest.com \ frontend \ modules \ - Oughtem