Steve Bals
Steve Bals

Reputation: 1979

how to create separate blade for menu , content , sidebar and footer

my html code is

<html>
<head>
</head>
<body>
<div id="content">
<div id="menu"></div>
<div id="container"></div>
<div id="sidebar"></div>
<div id="footer"></div>
<div>
</body>
</html>

master.blade.php is

<html>
    <head>
    @yield('title')
    @yield('css')
@yield('js')
    </head>
    <body>
    <div id="content">
    <div id="container"></div>
    <div>
    </body>
    </html>

menu.blade.php is

<div id="menu"></div>

sidebar.blade.php is

<div id="sidebar"></div>

footer.blade.php is

<div id="footer"></div>

my view file is home.blade.php

@extends('layouts.master')
@section('title')
<title>:: Login ::</title>
@stop
@section('js')
@stop
@extends('layouts.menu')    
@extends('layouts.sidebar')    
@extends('layouts.footer')    

router.php

Route::get('home', array('uses' => 'HomeController@home'));

HomeController.php is

public function home()
    {
        return View::make('home');
    }

id i run

localhost/project/public/index.php/home

it shows only master blade file content , y sidebar , footer and menu not showing , what is the mistake.

Upvotes: 5

Views: 9638

Answers (1)

Antonio Carlos Ribeiro
Antonio Carlos Ribeiro

Reputation: 87719

Create a your layout @including your menu:

<html>
    <head>
        <title>@yield('title')</title>
        @yield('css')
        @yield('js')
    </head>
    <body>
    <div id="content">
        <div id="container">
            @include('menu')
            @yield('content')
        </div>
    </body>
</html>

Your menu:

<div id="menu">
    <ul>
        <li>
            Item 1
        </li>
        <li>
            Item 2
        </li>
        <li>
            Item 3
        </li>
    </ul>
</div>

And your view:

@extends('layouts.master')

@section('title')
    :: Login ::
@stop

@section('content')
    This is your content!
@stop

Upvotes: 4

Related Questions