Jump to content

Different menu color for current page


rrdemello

Recommended Posts

Hello,Can anyone give me a quickstart with a piece of sample code for the following problem?I use a CSS based menu, with menu-items in color white. When I select an item, it colors red and then I go to the corresponding page. At this 'current' page I would like the chosen menu-item still to be red so that it stands out from the other menu-items. But that is not the case: it takes on the original white color again. Thanks,Ruud

Link to comment
Share on other sites

One way is to repeat the menu on each page and then manually change the CSS using inline styles on that page. Thats fine if you've got about 10 pages or less, as its not much time to go thru and edit them all.How many pages have you got?:)

Link to comment
Share on other sites

One way is to repeat the menu on each page and then manually change the CSS using inline styles on that page. Thats fine if you've got about 10 pages or less, as its not much time to go thru and edit them all.How many pages have you got?:)
The number of pages is not a problem, they are few. However, the inline styles should only change the color when the page is active, so I need a condition like "when the url == page-url", then change the colors. And I don't know how to retrieve the active url.
Link to comment
Share on other sites

You can use $_SERVER['SCRIPT_NAME'] to get the URL of the current page. You can break up the URL to get the filename and write out something in a style tag on the top to style an element with a certain ID that relates to the filename.

Link to comment
Share on other sites

You can use $_SERVER['SCRIPT_NAME'] to get the URL of the current page. You can break up the URL to get the filename and write out something in a style tag on the top to style an element with a certain ID that relates to the filename.
Thanks, that's the right track.
Link to comment
Share on other sites

Archived

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

×
×
  • Create New...