Jump to content

Identifying current page


sticks464

Recommended Posts

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.