doupin5667 2017-10-12 19:55
浏览 62

如何知道在laravel中访问哪条路线?

I'm starting a project php with Laravel framework 5!

I need to make a section in my project laravel for a dashboard to know which page is visited by the user.

Example: Menu Dashboard [Home -> Profile -> Settings -> Account ]

And i need know what is visited and show to user: ex: Dashboard -> Home

The question is, I use the Blade template of laravel to maker my fixed layout page and use for the other views pages. how to know which view is being accessed to mark in my blade layout?

<html>
    <head>
        <title>DashBoard</title>
    </head>
    <body>

        @section('sidebar')
        <section id="breadcrumb">
          <div class="container">
            <ol class="breadcrumb">
              <li><a href="dashboard.html">Dashboard</a></li>
              <li><a href="profile.html">Profile</a></li>
              <li><a href="settings.html">Settings</a></li>
              <li><a href="account.html">Account</a></li>
            </ol>
          </div>
       </section>
        @show

        <div class="container">
            @yield('content')
        </div>
    </body>
</html>
  • 写回答

1条回答 默认 最新

  • dsvjw20866 2017-10-12 20:00
    关注

    You can check the url/route using the Request::is() function, so setting something like:

    <li class="{{ Request::is("dashboard") ? "active" : "" }}">
      <a href="dashboard.html">Dashboard</a>
    </li>
    ...
    

    To set one of your <li> items as active, which you'd then just style slightly different than non-active ones.

    Note that the value passed to is() has to match the way you have the route defined in routes.php: (Note: Omit leading / in is())

    Route::get("/dashboard", ...);
    ...
    
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据