【问题标题】:Loading footer in error pages based on routing group基于路由组在错误页面中加载页脚
【发布时间】:2016-04-08 21:17:19
【问题描述】:

我有默认的errors/404.blade.php,我有一个路由组,比如admin(我可能有更多的路由组)。

现在,当然,我为默认路由和每个路由组设置了单独的页眉和页脚模板。

.
.     
|-- resources
    |-- views
      |-- ..                   (other views)
      |-- errors
          |-- 404.blade.php
          |-- 503.blade.php
      |-- partials
          |-- ..
          |-- header.blade.php
          |-- footer.blade.php
      |-- pages
          |-- ..
          |-- admin
              |-- ..
              |-- partials
                  |-- header.blade.php
                  |-- footer.blade.php

假设我在我的site.com/admin/ 路线中,我通过访问这样的页面得到 404 errorsite.com/admin/some-non-existent-page

默认情况下,我的errors/404.blade.php 被硬编码为使用/views/partials/footer.blade.php

我怎样才能使它成为dynamic,以便它显示我当前所在的路由组的页脚或默认页脚(如果我在其中一个主页上)?

【问题讨论】:

    标签: php laravel laravel-5 blade laravel-routing


    【解决方案1】:

    使用 Request::segment()

    例如取这个网址... stackoverflow.com/questions/34605065/loading-footer-in-error-pages-based-on-routing-group

    请求::segment(2)= 问题

    请求::segment(3)= 34605065

    使用 if else 条件与 Request::segment()..我认为这将解决您的问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-02-25
      • 2014-05-14
      • 2021-10-07
      • 2020-04-03
      • 1970-01-01
      • 1970-01-01
      • 2013-05-19
      相关资源
      最近更新 更多