webguync Posted October 4, 2007 Share Posted October 4, 2007 I am using CSS to indicate which page you are on and PHP to use this menu as an include while still being able to determine the 'you_are_here" CSS. work great on the home page http://www.warriorsarise.org/index.php you will see that the indicator is that you are on the home page however, when you go here: http://www.warriorsarise.org/About_Us/index.php you will see that the menu indicates that you are still on the home page. This is what I am having an issue with. I know why it is doing this. It is because my directory is set up as Contact_Us/index.php, Itinerary/index.php etc. how do i alter my code, so that it picks up the right pages? my PHP as it is now <?php $currentPage = basename($_SERVER['SCRIPT_NAME']);?> <ul id="top_menu"> <li><a href="../index.php"<?php if ($currentPage == 'index.php'){echo 'id="active"';} ?>> Home</a></li> <li><a href="../About_Us/index.php"<?php if ($currentPage == '../About_Us/index.php') {echo 'id="active"';} ?>>About Us</a></li> <li><a href="../OnlineSermons/index.php"<?php if ($currentPage == '../OnlineSermons/index.php') {echo 'id="active"';} ?>>Online Sermons and Video</a></li> <li><a href="../Itinerary/index.php"<?php if ($currentPage == '../Itinerary/index.php') {echo 'id="active"';} ?>>Itinerary</a></li> <li ><a href="../Request_Visit/index.php"<?php if ($currentPage == '../Request_Visit/index.php') {echo 'id="active"';} ?>>Request a Visit to Your City</a></li> <li><a href="../Links/index.php"<?php if ($currentPage == '../Links/index.php') {echo 'id="active"';} ?>>Links</a></li> <li><a href="../Contact_Us/index.php"<?php if ($currentPage == '../Contact_Us/index.php') {echo 'id="active"';} ?>>Contact Us</a></li> </ul> Quote Link to comment https://forums.phpfreaks.com/topic/71750-css-and-menu-includes-issue/ Share on other sites More sharing options...
teng84 Posted October 4, 2007 Share Posted October 4, 2007 try if($_SERVER['REQUEST_URI'] == 'index.php') Quote Link to comment https://forums.phpfreaks.com/topic/71750-css-and-menu-includes-issue/#findComment-361333 Share on other sites More sharing options...
teng84 Posted October 4, 2007 Share Posted October 4, 2007 or try $array=explode('/',$_SERVER['REQUEST_URI']); $currentPage= $array[count($array)-2]; i guess that is all you need just modify it base on how you neeed that Quote Link to comment https://forums.phpfreaks.com/topic/71750-css-and-menu-includes-issue/#findComment-361337 Share on other sites More sharing options...
webguync Posted October 4, 2007 Author Share Posted October 4, 2007 I tried this: <?php $currentPage = basename($_SERVER['SCRIPT_NAME']);?> <ul id="top_menu"> <li><a href="../index.php"<?php if($_SERVER['REQUEST_URI'] == 'index.php'){echo 'id="active"';} ?>> Home</a></li> <li><a href="../About_Us/index.php"<?php if ($_SERVER['REQUEST_URI'] == 'About_Us/index.php') {echo 'id="active"';} ?>>About Us</a></li> <li><a href="../Online_Sermons/index.php"<?php if ($_SERVER['REQUEST_URI'] == '../Online_Sermons/index.php') {echo 'id="active"';} ?>>Online Sermons and Video</a></li> <li><a href="../Itinerary/index.php"<?php if ($_SERVER['REQUEST_URI'] == '../Itinerary/index.php') {echo 'id="active"';} ?>>Itinerary</a></li> <li ><a href="../Request_Visit/index.php"<?php if ($_SERVER['REQUEST_URI'] == '../Request_Visit/index.php') {echo 'id="active"';} ?>>Request a Visit to Your City</a></li> <li><a href="../Links/index.php"<?php if ($_SERVER['REQUEST_URI'] == '../Links/index.php') {echo 'id="active"';} ?>>Links</a></li> <li><a href="../Contact_Us/index.php"<?php if ($_SERVER['REQUEST_URI'] == '../Contact_Us/index.php') {echo 'id="active"';} ?>>Contact Us</a></li> </ul> but it doesn't give me the id="active" that I need to set the you are on this page css See anything that might be wrong? Quote Link to comment https://forums.phpfreaks.com/topic/71750-css-and-menu-includes-issue/#findComment-361389 Share on other sites More sharing options...
teng84 Posted October 4, 2007 Share Posted October 4, 2007 <? $array=explode('/',$_SERVER['REQUEST_URI']); $currentPage= $array[count($array)-2]; ?> <ul id="top_menu"> <li><a href="../index.php"<?php if(count($array)<=1){echo 'id="active"';} ?>> Home</a></li> <li><a href="../About_Us/index.php"<?php if ($currentPage == 'About_Us') {echo 'id="active"';} ?>>About Us</a></li> <li><a href="../Online_Sermons/index.php"<?php if ($currentPage == 'Online_Sermons') {echo 'id="active"';} ?>>Online Sermons and Video</a></li> <li><a href="../Itinerary/index.php"<?php if ($currentPage == 'Itinerary') {echo 'id="active"';} ?>>Itinerary</a></li> <li ><a href="../Request_Visit/index.php"<?php if ($currentPage == 'Request_Visit') {echo 'id="active"';} ?>>Request a Visit to Your City</a></li> <li><a href="../Links/index.php"<?php if ($currentPage== 'Links') {echo 'id="active"';} ?>>Links</a></li> <li><a href="../Contact_Us/index.php"<?php if ($currentPage == 'Contact_Us') {echo 'id="active"';} ?>>Contact Us</a></li> </ul> try Quote Link to comment https://forums.phpfreaks.com/topic/71750-css-and-menu-includes-issue/#findComment-361391 Share on other sites More sharing options...
webguync Posted October 4, 2007 Author Share Posted October 4, 2007 thanks, but that doesn't seem to be working either. not producing the id="active" on the current page Quote Link to comment https://forums.phpfreaks.com/topic/71750-css-and-menu-includes-issue/#findComment-361415 Share on other sites More sharing options...
teng84 Posted October 4, 2007 Share Posted October 4, 2007 try to view source to find if you realy print it Quote Link to comment https://forums.phpfreaks.com/topic/71750-css-and-menu-includes-issue/#findComment-361418 Share on other sites More sharing options...
webguync Posted October 4, 2007 Author Share Posted October 4, 2007 no it's not being printed in the source code. Quote Link to comment https://forums.phpfreaks.com/topic/71750-css-and-menu-includes-issue/#findComment-361655 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.