2012-12-03 28 views
2

有谁知道我该如何检查href是否等于当前页面链接在smarty?我想从菜单中添加一个“活动”类到链接。 我的代码是这样的有谁知道如何检查href是否等于当前页面链接smarty?

<div id="navigation-menu"> 
     <a href="index.php" class="active">Home</a> 
    <a href="index.php?page=how_it_works">How it Works</a> 
    <a href="index.php?page=prices">Prices</a> 
</div> 
+1

您可以使用'{$ smarty.get.page}' – andlrc

回答

3

认为你可以这样做:

<div id="navigation-menu"> 
    <a href="index.php"{if $smarty.get.page eq ''} class="active"{/if}>Home</a> 
    <a href="index.php?page=how_it_works"{if $smarty.get.page eq 'how_it_works'} class="active"{/if}>How it Works</a> 
    <a href="index.php?page=prices"{if $smarty.get.page eq 'prices'} class="active"{/if}>Prices</a> 
</div> 

,但不知道,不知道智者。

+0

@ defau1t获得'$ _GET ['page']'变量Im正在处理它;) – andlrc

+0

但是很遗憾,很少见到:) – defau1t

相关问题