One possible solution:
- pass the layout to the View as a variable (
$layout
), rather than defining a string in the view.
- create a second layout with only the
content
section defined.
- then you can call the
View::make()
from anywhere with the template set according to your needs.
Change the @extends
in the child view:
@extends((isset($layout)) ? $layout : 'layouts.base')
create your new "content only" layout: /app/views/layouts/content-only.blade.php:
// only this line in the file:
@yield('content')
then in normal use:
return View::make('child-view');
and when you want the content-only version:
return View::make('child-view')->with('layout', 'layouts.content-layout');
EDIT - updated to take into account the tip in Sheikh Heera's answer!