Reputation: 15656
How can a Yii2 application Controller (not a module controller) render a view that is provided by a module, assuming the module follows the directory structure outlined in the documentation?
Upvotes: 1
Views: 4943
Reputation: 18021
As mentioned in method render() you can specify view as:
So in the case of the module mentioned by you do this in the action:
return $this->render('@app/modules/forum/views/default/index');
This will render the view with applied layout of the main application. To use module's layout add this as well in the action:
$this->layout = '@app/modules/forum/views/layouts/main';
This assumes view default/index
and layout main
in the forum
module.
Upvotes: 6