是否有可能在smarty的当前页面上添加新类以与类.nav-link链接?
{foreach FaMenu::gi()->get('top') menu}
{if $menu->sub}
<li class="list-item dropdown dropdown--relative">
<a href="#" class="nav-link dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">{$menu->name}
<span class="caret"></span></a>
<ul class="dropdown-menu dropdown-menu--simple" role="menu">
{foreach $menu->sub sub}
<li class="dropdown__item"><a class="dropdown__link" href="{$sub->url}" {if $sub->blank}target="_blank"{/if}>{$sub->name}</a></li>
{/foreach}
</ul>
</li>
{else}
<li class="list-item">
<a class="nav-link active" {if $menu->blank}target="_blank"{/if} href="{$menu->url}">{$menu->name} <span class="sr-only">(current)</span></a>
</li>
{/if}
{/foreach}
答案 0 :(得分:0)
您可以获取当前位置
{assign var='current_location' value="`$smarty.server.HTTP_HOST``$smarty.server.REQUEST_URI`"}
并将其与菜单项url进行比较,如果匹配,则该项目处于活动状态