dongya1875 2013-05-23 19:12
浏览 42
已采纳

REQUEST_URI在活动链接中设置样式

I have a menu that i'm including in my site pages, i want to set a style to the active document link in the menu, and this is the way i'm doing that:

<ul>
        <li><a href="slider.php" title="Slider" class="<?php 
 if ($_SERVER["REQUEST_URI"] == ("/cms/app/slider.php")){echo 'active' ;
 }else{ 'not-active';} ?>">Slider</a></li></ul>

So, this works as expected, when "slider.php" is an static document, but is not, it could be "slider.php?url=some-slide-in-db" also; or "store.php?id=4" (or any other id number in db), i just don't know how to implement this method in dynamic pages. ¿Can you give me a hand? thanks!

  • 写回答

2条回答 默认 最新

  • dongluo9156 2013-05-23 19:33
    关注

    @Sam i used your clue and it works perfect! code:

    <?php $urlsite=$_SERVER["QUERY_STRING"]; ?>
    
    <li><a href="slider.php" title="Slider" class="<?php 
                if ($_SERVER["REQUEST_URI"] == ("/campanario/cms/app/slider.php") | $_SERVER["REQUEST_URI"] == ("/campanario/cms/app/slider_edit.php?$urlsite")){echo 'active' ;}
    
                else{ 'not-active';} ?>">Slider</a></li>
    

    Thanks!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?