1

This is my scenario:

I have made a main.blade.php and it contains the following code:

<!DOCTYPE html>
<html>
    <head>
        <title>{{ $title }}</title>
    </head>
    <body>
        <div id='header'>
            @yield('header')
        </div>
        <div id='main-wrapper'>
             @yield('content')
        </div>
        <div id='footer'>
            @yield('footer')
        </div>
    </body>
</html>

And then this is the controller:

class Userindex extends BaseController
{
    protected $layout = "main";
    function register ()
    {
        $this->layout = View::make("user.register")
               ->with("title","Registration"); 
    }
}

Here is the register.blade.php in user folder:

@extends('main')

@section('content')
    <p>This the content of the page register.</p>
@stop

My PROBLEM: I have two other pages as header.blade.php and footer.blade.php that I don't know how should I include them into the register.blade.php

1 Answer 1

2

Do a little adjustment to you layout file, replace @yield with @include and that's it!

<!DOCTYPE html>
<html>
    <head>
        <title>{{ $title }}</title>
    </head>
    <body>
        <div id='header'>
            @include('partials.header')
        </div>
        <div id='main-wrapper'>
             @yield('content')
        </div>
        <div id='footer'>
            @include('partials.footer')
        </div>
    </body>
</html>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.