如何覆盖控制器用于渲染第三方模块中的视图的布局?
@msushil 从未接受过答案,所以我可能在这里浪费时间。我发布这个是因为它将来可能会帮助其他人,因为我非常怀疑 OP 是否会为这个问题选择答案......
您可以从视图中更改布局。在 Yii2 中,你通过 $this->context
引用你的控制器。因此,您可以像这样更改布局:
$this->context->layout = 'new-layout';
在相对操作中:
public function actionYourAction($id)
{
$this->layout = 'yourNewLayout';
return $this->render('yourView', ['model' =>$model]);
}