Include views


I want to display different view for different controller in one view!

What is the best practices for this?

Now i have called de views from another controller like this:

echo \Yii::$app->view->render('@app/views/anothercontroller/view',[

                        'datamodel' => $model2,


This is the beste method to include views in one view?

Thanks for help

you are on the right track render is how usually you render a view or a partial view.

if you are calling it in a view or controller, you don’t need to reference the full component you can call render on current context like so

echo $this->render('@app/views/anothercontroller/view', [

    'datamodel' => $model2,