Dynamic Layout in Laravel

BaseController:

class BaseController extends Controller {

/**
* Setup the layout used by the controller.
*
* @return void
*/

/*Set a layout properties here, so you can globally
call it in all of your Controllers*/
protected $layout = ‘layouts.default’;

protected function setupLayout()
{
if ( ! is_null($this->layout))
{
$this->layout = View::make($this->layout);
}
}

}


class HomeController extends BaseController {

public function showHome()
{
/*now you can control your Layout it here */
$this->layout->title= “Hi I am a title”; //add a dynamic title
$this->layout->content = View::make(‘home’);
}

}

 

source: http://teknosains.com/i/tutorial-dynamic-layout-in-laravel-4

Blogbook : PHP | Javascript | Laravel | Corcel | CodeIgniter | VueJs | ReactJs | WordPress