Laravel 4.1 Request :: is对于活动菜单不起作用 [英] Laravel 4.1 Request::is for active menu not working

查看:49
本文介绍了Laravel 4.1 Request :: is对于活动菜单不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图根据laravel 4.1中的路线激活菜单,我的尝试是:

I'm trying to make a menu active depending on route in laravel 4.1, my attempt:

<li
   {{{ (Request::is('/core') ? 'class="active"' : '') }}}><a href="{{{ URL::to('/core') }}}">Control Panel</a>
</li>

我的路线:

 Route::get('/core', 'CoreController@Showindex');

这不会引发任何错误,只是简单地将其忽略即可.任何帮助表示赞赏.

This is not throwing any errors just simply ignored. any help is appreciated.

推荐答案

已更改为:

<li
   {{{ (Request::is('/core') ? 'class=active' : '') }}}><a href="{{{ URL::to('/core')  }}}">Control Panel</a>
</li>

'class="active"''class=active'

对于<li>标签而不是<a>标签,这种方法可以正常工作,需要这样使用:

This working fine for <li> tag but not <a> tag, needs to be used like so:

<a href="{{{ URL::to('core') }}}" class="list-group-item {{{ (Request::is('core') ? 'active' : '') }}}">Overview</a>

这篇关于Laravel 4.1 Request :: is对于活动菜单不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆