如何为菜单,内容,侧边栏和页脚创建单独的刀片

时间:2014-02-22 11:23:49

标签: php html laravel-4

我的HTML代码是

<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是

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

menu.blade.php是

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

sidebar.blade.php是

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

footer.blade.php是

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

我的视图文件是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是

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

我正在运行

localhost/project/public/index.php/home

它只显示主刀片文件内容,y侧边栏,页脚和菜单未显示,错误是什么。

1 个答案:

答案 0 :(得分:4)

在菜单中创建您的布局@including

<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>

您的菜单:

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

您的观点:

@extends('layouts.master')

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

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