2013-05-26 36 views
6

Tôi gặp sự cố khi hiển thị chế độ xem trong bộ điều khiển của mình. Tôi hiện đang chạy Laravel 4 và bên dưới là mã của tôi. (BTW, tôi vẫn đang học Laravel đặc biệt là phiên bản mới nhất chưa được phát hành. Tôi thấy đó là một ý tưởng tồi khi học từ các phiên bản cũ hơn vì có vẻ như có nhiều thay đổi cho phiên bản hiện tại.)Bố cục chính của Laravel 4 không hiển thị

controllers/PluginsController.php

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

views/plugins/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 

views/templates/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> 
+0

Câu hỏi Vì vậy, tốt, tôi đã cùng một vấn đề – M98

Trả lời

8

Sử dụng @extends thay vì @layout đã giải quyết được sự cố của tôi.

15

bạn phải sử dụng @extends thay vì @layout, và @stop thay vì @endsection

Các vấn đề liên quan