Forum Moderators: not2easy

Message Too Old, No Replies

CSS navigation include issue

         

jonnyd8

8:01 am on Sep 24, 2007 (gmt 0)

10+ Year Member



Hi there. Will try to explain this as easily as possible.

I have a menu with five different pages.

I have created this menu 5 times and inserted it into each page each time highlighting the 'active' tab to show which page the user is on.

You probable know what my issue is by now. Usually i use includes for menus however how do you set different active tabs on different pages but for one include?

Any help would be great as Im sure it's really simple.

Robin_reala

11:40 am on Sep 24, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well you could sort of replicate this using CSS3's :target [w3.org] pseudoclass but that's definitely not the best way to go about it. You'd be much better off using some server-side language to set the appropriate class. Most of them let you pass through variables through to includes, for example in PHP you can do this:

<?php $page="page_id"; include('templates/nav.php')?>

then reference your page variable from within nav.php to set the appropriate class.

jonnyd8

2:59 pm on Sep 24, 2007 (gmt 0)

10+ Year Member



That's great!

Thankyou very much.

Jonny