dongshan9338 2014-04-02 05:38 采纳率: 0%
浏览 42
已采纳

从刀片扩展功能不起作用

I have a problem, I don't know why but when I extend a blade template then I call it, it prints an empty page in my browser.

In my /app/views/layout.blade.php

  1. <div>
  2. @yield('main')
  3. </div>

In my /app/views/error/notfound.blade.php

  1. @extends('layout')
  2. @section('main')
  3. <myhtmlcode>
  4. </myhtmlcode>
  5. @stop

My notfound template is called when I catch a NotFoundHttpException

  1. App::error(function(\Symfony\Component\HttpKernel\Exception\NotFoundHttpException $exception, $code)
  2. {
  3. return View::make('error.notfound');
  4. });

Every other View::make work fine.. this one worked fine before.. but I certainly made an invisible mistake. I need your hindsight guys.

Thanks.

  • 写回答

2条回答 默认 最新

  • doujuan2688 2014-04-02 06:10
    关注

    Ok I'm obvious..

    So I prefix all my routes

    1. Route::group(array('prefix' => '{lang}', 'before' => 'set.lang'), function($lang) {
    2. });

    So I tried to call my template notfound.blade.php inside my route::group with a route test and it didn't work too.. But there was a php warning telling me that he can't found the $lang variable in my layout.blade.php !

    So I guess that when I returned my view by catching the notFoundHtppException there was this error too but laravel didn't show me anything.. so I just had to inject the $lang variable in my View::make like this in app/start/global.php

    1. App::error(function(\Symfony\Component\HttpKernel\Exception\NotFoundHttpException $exception, $code)
    2. {
    3. return View::make('error.notfound', ['lang' => App::getLocale()]);
    4. });

    Now it works like a charm..

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部