Reputation: 9351
I have a template like this.
<div class="content">
@yield('content') //this area should load different files on different URI's
</div>
If I load .com/register
, it should load register.blade.php
at the place of @yield.
If I load something else, it will load that view.
I'll define which file should be loaded in Routes.php
with Route::get();
Full source is here for easier readability: http://pastebin.com/t2Md20r9 so you can see what I did so far.
What should be done?
Upvotes: 0
Views: 63
Reputation: 12503
You're very close, just extend your layout in register.blade.php
.
1.Put your template file in views/layouts/master.blade.php
2.In your register.blade.php put
@layout('layouts.master')
in Laravel 4
@extend('layouts.master')
on top.
3.Now use return View::make('register');
Upvotes: 2
Reputation: 1190
You can pass it in your Route.php file something like this:
Route::get('your_page', function() {
View::make('your_page')->with('contentTemplate', 'register');
}
Route::get('other_page', function() {
View::make('other_page')->with('contentTemplate', 'other_content');
}
And in your_page, do
<div class="content">
@render($contentTemplate)
</div>
Upvotes: 0