$this->layout->content = View::make('user.register')->with('success', '1');
mferrara said:
$this->layout->content = View::make('user.register')->with('success', '1');
Nope. Still does not work. I've added that I'm using "protected $layout = 'master';", if that changes anything.
This is not a direct answer but I prefer the other method of managing templates. It allows for cleaner controllers.
You don't need to make any changes to your master template.
user.register.blade.php
@extends('master')
@section('content')
...
@if ($success == 1)
<p>Success!</p>
@else
<p>Error!</p>
@endif
...
@stop
UserController.php
...
return View::make('user.register', array('success' => '1'));
koomai said:
This is not a direct answer but I prefer the other method of managing templates. It allows for cleaner controllers.
You don't need to make any changes to your master template.
user.register.blade.php
@extends('master') @section('content') ... @if ($success == 1) Success! @else Error! @endif ... @stop
UserController.php
... return View::make('user.register', array('success' => '1'));
Thanks! Will definitely check it out. I assume I don't need to set the $layout in the controller anymore as the extend takes care of it?
I agree with Koomai.
I had this issue when I started, but I now use the a variation of the way Koomai suggests, and it works well.
I think, perhaps, an alternative might be to share the variable across the views explicitly.
I think this does it:
View::share('success', $success);
Let us know how you got on.
Al
Edit: Just to be clear, this View::share()
line would go before the View::make()
method)
Awesome! Koomai's method worked fantastic. Thanks a lot! :)
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community