2016-03-11 65 views
1

我試圖切換基於http referer的主佈局。我目前正在拉動正確的模板,但刀片中的內容沒有顯示 - 沒有錯誤。 $ layout正確傳遞,因爲模板基於referer更改。這個404刀片是唯一的問題。其他刀片可以很好地佈局佈局。刀片未顯示刀片內容@include - Laravel 4.2

routes.php文件

App::missing(function($exception) { 
    $referer = URL::previous(); 
    $layout = (strpos($referer,'ext')) ? 'layouts.ext.master' : 'layouts.master'; 
    return Response::view('error-404', compact('layout'), 404); 
}); 

誤差404.blade.php

@include($layout) 

@section('page_content') 
    content... 
@stop 

佈局(二者/layouts/ext/master.blade.php和/layouts/master.blade.php包含HTML包裝。)

@yield('page_content') 

回答

0

使用@extends('layouts.ext.master'),而不是@include('layouts.ext.master')

+0

'錯誤異常處理程序:查看[@extends( 'layouts.master')]不是found.'難道不如何包括把手,由於讀? layouts.master確實存在 – Klav

+0

你是對的,但不像你所描述的那樣。如果你更新你的答案來解釋爲什麼不應該使用@include,而是@extends會有幫助。 '@include($ layout)'變成'@extends($ layout)' – Klav

-1

請使用

return View::make('error-404', compact('layout'));