Search code examples
phplaravellaravel-3

How can I make content area change on different requests?


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?


Solution

  • 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');