Support the ongoing development of Laravel.io →
Views Blade
Last updated 2 years ago.
0
$this->layout->content = View::make('user.register')->with('success', '1');
Last updated 2 years ago.
0

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.

Last updated 2 years ago.
0

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'));
Last updated 2 years ago.
0

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?

Last updated 2 years ago.
0

Yes, that's correct.

Last updated 2 years ago.
0

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)

Last updated 2 years ago.
0

Awesome! Koomai's method worked fantastic. Thanks a lot! :)

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.