In my page controller I have
$this->layout->content = View::make('authentication/login')->with('page_title','title');
I am using a blade file for my template. In the head of the html, I have
<title>{{$page_title}}</title>
I get an error that $page_title is undefined.
What I want ideally is a $data=array('page_title'=>'Login','second_item'=>'value').... But as I cannot get the basic passing of a variable to a view working, I am sticking with that first of all.
There are many ways to achieve this, as @Gravy pointed out, but judging by the way she is trying to write the code, the solution would be:
$data = array();
$this->layout->with('data', $data);
$this->layout->content = View::make('home');
See more here: http://forums.laravel.io/viewtopic.php?pid=58548#p58548
$data =
[
'page_title' => 'Login',
'second_item' => 'value'
...
];
return View::make('authentication/login', $data);
// or
return View::make('authentication/login', compact('data'));
// or
return View::make('authentication/login')->with($data);
// or
return View::make('authentication/login')->with(['page_title' => 'Login', 'second_item' => 'value']);
// or
return View::make('authentication/login')->with(array('page_title' => 'Login', 'second_item' => 'value'));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With