TheFilmGod Posted July 20, 2007 Share Posted July 20, 2007 I would like to make a php script. I have 8 links in the menu. Depending on the variable "current" (page) one of those corresponding links would have a certain class created by the php. So if it was contact us -> the contact us link would be given a special class, while the others would not. This would allow that certain link to have a different color and let users know what section they are at. I want a header that is the same for all pages. Thus, making a separate one 4 each section is not practical. Any ideas? Link to comment https://forums.phpfreaks.com/topic/60891-php-and-css/ Share on other sites More sharing options...
benjaminbeazy Posted July 20, 2007 Share Posted July 20, 2007 something like this should work... $page = $_SERVER['PHP_SELF']; <a href="whatever.php" class="<?php if($page == "whatever.php"){ echo "class2"; }else{ echo "class1"; }?>">Whatever</a> Link to comment https://forums.phpfreaks.com/topic/60891-php-and-css/#findComment-302991 Share on other sites More sharing options...
TheFilmGod Posted July 20, 2007 Author Share Posted July 20, 2007 So you are saying I should have that script for every link? Is that considered a large script? Link to comment https://forums.phpfreaks.com/topic/60891-php-and-css/#findComment-302994 Share on other sites More sharing options...
AndyB Posted July 20, 2007 Share Posted July 20, 2007 http://css.maxdesign.com.au/listamatic/ - there's your menu solution, with php changing the css class of the current page link. The same header for each page is done using include(). Link to comment https://forums.phpfreaks.com/topic/60891-php-and-css/#findComment-302995 Share on other sites More sharing options...
AndyB Posted July 20, 2007 Share Posted July 20, 2007 Is that considered a large script? Hardly. Link to comment https://forums.phpfreaks.com/topic/60891-php-and-css/#findComment-302996 Share on other sites More sharing options...
TheFilmGod Posted July 20, 2007 Author Share Posted July 20, 2007 http://css.maxdesign.com.au/listamatic/ - there's your menu solution, with php changing the css class of the current page link. The same header for each page is done using include(). Umm. I went to the link and there are a billion different links to other pages on it! Which one? I searched the word "php" and didn't find it... ??? Yes, I'm using include() Link to comment https://forums.phpfreaks.com/topic/60891-php-and-css/#findComment-303000 Share on other sites More sharing options...
AndyB Posted July 20, 2007 Share Posted July 20, 2007 Umm. I went to the link and there are a billion different links to other pages on it! Which one? You want it all handed to you on a plate??? Look at the various menu alternatives. Find one you like. Check the CSS and HTML code given for it. See how simple it is to add a little bit of php to determine if a link is the same as the 'current' page and in that case change its class. Link to comment https://forums.phpfreaks.com/topic/60891-php-and-css/#findComment-303003 Share on other sites More sharing options...
TheFilmGod Posted July 20, 2007 Author Share Posted July 20, 2007 http://css.maxdesign.com.au/listamatic/ - there's your menu solution, with php changing the css class of the current page link. Well, I got the menu finished. Already done! I was just wondering about the php itself how to code it. I don't need help with the links themselves. And when you said "PHP CHANGING THE CSS CLASS" I thought their was an exact article with that in it. But I guess not... Thanks anyway Andyb! Link to comment https://forums.phpfreaks.com/topic/60891-php-and-css/#findComment-303008 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.