How do I pass a variable to the layout using Laravel' Blade templating? -
in laravel 4, controller uses blade layout:
class pagescontroller extends basecontroller {     protected $layout = 'layouts.master'; } the master layout has outputs variable title , displays view:
... <title>{{ $title }}</title> ... @yield('content') .... however, in controller appear able pass variables subview, not layout. example, action be:
public function index() {     $this->layout->content = view::make('pages/index', array('title' => 'home page')); } this pass $title variable content section of view. how can provide variable whole view, or @ least master layout?
if you're using @extends in content layout can use this:
@extends('master', ['title' => $title]) 
Comments
Post a Comment