2013-05-26 43 views
6

我無法在控制器中呈現視圖。我目前正在運行Laravel 4,下面是我的代碼。 (順便說一句,我仍然在學習Laravel,尤其是最新版本還沒有發佈,我發現從舊版本中學習是一個不好的主意,因爲目前的版本似乎有很多變化。)Laravel 4主佈局不呈現

控制器/ 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> 
+0

所以很好的問題,我有同樣的問題 – M98

回答

8

使用@extends而不是@layout解決了我的問題。

15

必須使用@extends代替@layout和@stop代替@endsection