简体   繁体   English

Laravel:在控制器方法中更改布局

[英]Laravel: Changing layout in controller method

I have a controller which, within a method, I want to specify a different layout for my view. 我有一个控制器,该控制器要在方法中为视图指定其他布局。 I would have thought the below would do the trick, however, I am getting: 我以为下面的方法可以解决问题,但是,我得到了:

Attempt to assign property of non-object 尝试分配非对象的属性

on the line where I am trying to reset the layout. 在我尝试重置布局的行上。

class My_controller extends Base_Controller {
    public $layout = "cms::layouts.default";

    ............

    public function get_list($status = "open")
    {
        $this->layout = 'cms::layouts.nowrap';
        $this->layout->strContent = View::make('cms::partials.orderdetails')
            ->with('xxxx', \CMS\XXX::method($xxx));
    }
    .................
}

Any ideas? 有任何想法吗? I'm using Laravel 3 for this one 我正在为此使用Laravel 3

I think that you have to do that : 我认为您必须这样做:

$this->layout = View::make('cms::layouts.nowrap');
$this->layout->strContent = ...;

It's the L4 solution but, after a small check, it seems to be the same pattern in L3. 这是L4解决方案,但经过一番检查,它似乎与L3中的模式相同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM