sticks464 Posted October 14, 2009 Share Posted October 14, 2009 Is there a method of showing the current page in the menu using php? The css I'm using works for showing the current page if using just html but not for php. I am using php to call my page content into a div with the following <?php if (isset($_GET['pg']) && $_GET['pg'] != "") { $pg = $_GET['pg']; if (file_exists('pages/'.$pg.'.php')) { @include ('pages/'.$pg.'.php'); } elseif (!file_exists('pages/'.$pg.'.php')) { echo 'Page you are requesting doesn´t exist'; } } else { @include ('pages/home.php'); } ?> And using this menu <div class="main_nav"> <ul> <li id="home"><a style="background-position: 0pt 0pt;" href="?pg=home">Home</a></li> <li id="services"><a style="background-position: 0px 0px;" href="?pg=services">Services</a></li> <li id="media"><a style="background-position: 0px 0px;" href="?pg=media">Media</a></li> <li id="testimonials"><a style="background-position: 0px 0px;" href="?pg=testimonials">Testimonials</a></li> <li id="bio"><a style="background-position: 0pt 0pt;" href="?pg=bio">Bio</a></li> <li id="contact"><a style="background-position: 0pt 0pt;" href="?pg=contact">Contact</a></li> </ul> </div> css for the menu div.main_nav { width: 750px; height: 83px; padding: 25px 0 0 28px; margin: 0 auto;} div.main_nav ul { float: left; padding: 19px 20px 0 0; } div.main_nav ul li { display: inline; } div.main_nav ul li a { float: left; display: block; height: 38px; text-indent: -9999px; margin-left: 15px; } div.main_nav ul li#contact a { background: url('../images/nav_cont.png') no-repeat; width: 113px; } div.main_nav ul li#bio a { background: url('../images/nav_bio.png') no-repeat; width: 71px; } div.main_nav ul li#testimonials a { background: url('../images/nav_test.png') no-repeat; width: 142px; } div.main_nav ul li#media a { background: url('../images/nav_media.png') no-repeat; width: 85px; } div.main_nav ul li#services a { background: url('../images/nav_serv.png') no-repeat; width: 118px; } div.main_nav ul li#home a { background: url('../images/nav_home.png') no-repeat; width: 80px; } div.main_nav ul li#home a:hover, div.main_nav ul li#services a:hover, div.main_nav ul li#media a:hover, div.main_nav ul li#testimonials a:hover, div.main_nav ul li#bio a:hover, div.main_nav ul li#contact a:hover { background-position: 0 -52px; } div.main_nav ul li.current a { background-position: 0 -104px!important; } Also, is there a way to show only the page name in the address bar instead of http://mysite/index.php?pg=services Quote Link to comment Share on other sites More sharing options...
martha Posted October 15, 2009 Share Posted October 15, 2009 i think it should work. Quote Link to comment 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.