Question

I am building the website and everything is fine in Localhost but when I made it online the active menu is not highlighted. Can you please help me to resolve it.

But when I create subfolder it works.

My code goes here :

<?php
$filename = $_SERVER['REQUEST_URI'];
$filename = substr($filename, 9);


?>

HTML :

<header id="header" class="container navbar">



                <nav id="menu" class="nav-collapse collapse default-menu">


                <ul id="menu-top-menu" class="nav">



                    <li <?php if($filename=='about-us'){?>class="current_page_item"<?php } ?>>
                    <a href="about-us" class="dropdown-toggle order" data-target="#">ABOUT</a>
                    </li>

                    <li <?php if($filename=='offers'){?>class="current_page_item"<?php }?>>
                        <a href="offers" class="order">OFFERS</a>

                    </li>


                    <li <?php if($filename=='membership'){?>class="current_page_item"<?php }?>>
                        <a href="membership" class="order">MEMBERSHIP</a></li>



                </ul>       
            </nav>
           <div class="clear"></div>   
    </header>

Please someone help me !

Was it helpful?

Solution

first try echo your $filename value what you getting and match like below

if your $filename has correct value then try to echo your text

<li <?php if($filename=='about-us'){echo 'class="current_page_item"';} ?>>

try with

$info = pathinfo($_SERVER['REQUEST_URI']);
 $filename = $info['filename'];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top