PHP Multiple navigation highlights
        Posted  
        
            by 
                Blackbird
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Blackbird
        
        
        
        Published on 2011-03-18T15:52:53Z
        Indexed on 
            2011/03/18
            16:10 UTC
        
        
        Read the original article
        Hit count: 265
        
php
I'm using this piece of code below to highlight the "active" menu item on my global navigation.
<?php
    $path = $_SERVER['PHP_SELF'];
    $page = basename($path);
    $page = basename($path, '.php');
?>
<ul id="nav">
    <li class="home"><a href="index.php">Home</a></li>
    <li <?php if ($page == 'search') { ?>class="active"<?php } ?>><a href="#">Search</a></li>
    <li <?php if ($page == 'help') { ?>class="active"<?php } ?>><a href="help.php">Help</a></li>
</ul>
All works great but, on a couple of pages, I have a second sub menu (sidebar menu) within a global page.
I basically need to add a OR type statement into the php somehow, but I haven't a clue a how.
Example of what i mean:
    <li <?php if ($page == 'help') OR ($page == 'help-overview') OR ($page == 'help-cat-1') { ?>class="active"<?php } ?>><a href="#">Search</a></li>
Thanks!
© Stack Overflow or respective owner