2012-12-03 27 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

相關問題