【发布时间】:2014-08-08 07:12:23
【问题描述】:
我有这个文件名为file-not-found.php 并具有不同的标题.. 我想要做的是根据路由名称或 url 段更改标题
在 CodeIgniter 我可以做到这一点
function blah(){
include('layout.registered.header')
include('layout.file-not-found')
}
function unregistered(){
include('layout.unregistered.header')
include('layout.file-not-found')
}
现在.. 我怎样才能在 Laravel Blade 模板中获得这个而不使用控制器.. 我只使用路线和视图
我尝试了下面的方法,它在IF中调用了extends,还在ELSE处调用了extends,因此它同时显示了2个布局
file-not-found.blade.php
@if (Route::currentRouteName() == 'file-not-found')
@extends('layouts.unregistered')
@else
@extends('layouts.registered')
@endif
路线
Route::get('/file-not-found', array('as' => 'file-not-found', function()
{
return View::make('pages.new.file-not-found');
}));
Route::get('registered/file-not-found', array('as' => 'registered', function()
{
return View::make('pages.new.file-not-found');
}));
【问题讨论】:
标签: php laravel laravel-4 blade