【问题标题】:Laravel 4 master layout not renderingLaravel 4主布局不渲染
【发布时间】:2013-06-12 10:41:00
【问题描述】:

我在控制器中渲染视图时遇到问题。我目前正在运行 Laravel 4,以下是我的代码。 (顺便说一句,我还在学习 Laravel,尤其是尚未发布的最新版本。我觉得从旧版本中学习是个坏主意,因为当前版本似乎有很多变化。)

控制器/PluginsController.php

class PluginsController extends BaseController {
    public function index()
    {
        return View::make('plugins.index')->with(array('title'=>"The Index Page"));
    }

视图/插件/index.blade.php

@layout('templates.master')

@section('header')
    <h1>The Header</h1>
@endsection

@section('content')
    testing the index.blade.php
@endsection


@section('footer')
    <div style="background:blue;">
        <h1>My Footer Goes Here</h1>
    </div>
@endsection

视图/模板/master.blade.php

 <!doctype>
 <html>
    <head>
        <meta charset="UTF-8" />
        @yield('meta_info')
        <title>{{$title}}</title>
        @yield('scripts')
    </head>
    <body>
        <div id="header">
            @yield('header')
        </div>

        <div id="wrapper">
            @yield('content')
        </div>

        <div id="footer">
            @yield('footer')
        </div>
    </body>
 </html>

【问题讨论】:

  • 这么好的问题,我也遇到了同样的问题

标签: laravel laravel-4


【解决方案1】:

您必须使用@extends 代替@layout,并使用@stop 代替@endsection

【讨论】:

    【解决方案2】:

    使用@extends 而不是@layout 解决了我的问题。

    【讨论】:

      猜你喜欢
      • 2013-07-24
      • 2021-07-26
      • 1970-01-01
      • 2017-12-14
      • 2021-09-20
      • 2013-05-12
      • 2016-11-12
      • 1970-01-01
      相关资源
      最近更新 更多