Fraser
Fraser

Reputation: 14244

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

Upvotes: 0

Views: 372

Answers (1)

Alexandre Butynski
Alexandre Butynski

Reputation: 6746

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.

Upvotes: 1

Related Questions