Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel template - passing data to layout

Tags:

php

laravel

How to pass data to layout file? I can only access the passed data on the content page but not on the layout file.

public function get_index($name){
    return View::make('widget.'.$name)
            ->with("title", ucwords($name).' ‹ Document Management System');
}
like image 303
Ram Guiao Avatar asked Dec 16 '22 14:12

Ram Guiao


2 Answers

Use

View::share('data', $data);

on your before filter or in __construct of your Base_Controller.

like image 159
Muhammad Usman Avatar answered Dec 28 '22 02:12

Muhammad Usman


You need a global view variable. I think you need to look at View::share('title', $title); I also think you can chain it with ->shares('title', $title)

like image 21
Dave Ganley Avatar answered Dec 28 '22 02:12

Dave Ganley