之前得到我使用Laravel 4Laravel 4內容佈局
的新鮮構建今天我有一個dashboardController
class DashboardController extends BaseController {
protected $layout = 'layouts.dashboard';
public function index()
{
$this->layout->content = View::make('dashboard.default');
}
}
我有一個簡單的路線
Route::get('/', '[email protected]');
我有一個視圖中的刀片佈局/ layouts/dashboard.blade.php 爲了保存所有實際HTML中的每個人生病,請使用模擬。
<html>
<head>
<title></title>
</head>
<body>
@yield('content')
</body>
</html>
我在視圖/儀表板/默認葉片文件具有以下(編輯爲簡單起見)
@section('content')
<p>This is not rocket science</p>
@stop
出於某種原因,內容獲取佈局之前產生。
你的BaseController是否做了特別的事情?確保它有'setupLayout()'方法:https://github.com/laravel/laravel/blob/master/app/controllers/BaseController.php - 否則,你可能不需要發佈更多的dashboard.default文件。 –
是的,檢查'BaseController'上的'setupLayout()'。我只是建立了一個1:1的環境,其中包含你在這裏發佈的內容並且它可以工作(至少我想它是這樣的 - 你沒有提供預期的結果和實際結果)。你也可以嘗試'$ this-> layout-> nest('content','dashboard.default')'而不是'$ this-> layout-> content' ... – jolt