Jump to content

PHP: navigation help


kinghokum

Recommended Posts

Hi All,

I have a site that consists of 24 pages.

Instead of adding a menu to every page, i plan of just including a file that contains the menu called 'nav.php'.

 

However the menu is a horizontal drop down menu, and my issue is that i want to know if there's a way that if you visit the child links

of the navigation, the parent would be 'selected' using CSS.

 

So for instance i have this menu in my 'nav.php' file:

 

<ul is "nav">
<li><a href="#" class="home">Home</a>
<ul>
<li><a href="#">page 1</a></li>
<li><a href="#">page 2</a></li>
</ul>
</li>

<li><a href="#" class="products">Products</span></a>
<ul>
<li><a href="#">Page 3</a></li>
<li><a href="#">Page 4</a></li>
<li><a href="#">Page 5</a></li>
</ul>
</li>
</ul>

 

 

 

So if you were to visit 'Page 1' the parent link 'Home' would be 'selected'.

 

Usually, If i was to actually put this menu on the home page i would just add :

 

 

<ul is "nav">
<li><a href="#" class="home [b]selected[/b]">Home</a>
<ul>
<li><a href="#">page 1</a></li>
<li><a href="#">page 2</a></li>
</ul>
</li>
...

 

with this CSS :

 

#nav li .home.selected{
color: #ff1200;
}

 

 

But I'm wondering if there is a way using PHP that i can insert the navigation and sort through and basically say

"If this is Page 1, make HOME selected".

 

Any help is appreciated.

Thanks in advance

 

 

Link to comment
https://forums.phpfreaks.com/topic/160467-php-navigation-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.