Click to See Complete Forum and Search --> : css php rollover


jesse.bo
05-05-2006, 03:32 PM
ok, I've got my CSS rollover navigation working just great.

I want it, however, to somehow check to see what the current page is and give the corresponding image an "in" state.

I would just change that for each page, however, the navigation is, of course in my header file, so that isn't possible.

Is there any sort of php go around so I can put in an if statement to tell the navigation to keep one clicked in?

Here's the code for the stylesheet:


#products{

height: 20px;
width: 85px;
text-indent: 10000px;
overflow: hidden;
background: url(/images/nav/products.gif) top left no-repeat;
display: block;

}

#products:hover{

background-position: bottom left;

}

and here's the code for the corresponding nav button:

<a href="#" id="products">Home</a>

Thanks for the help

Jesse

www.coasttravelmugs.com (http://www.coasttravelmugs.com)

Little Goat
05-05-2006, 04:27 PM
ok, I've got my CSS rollover navigation working just great.

I want it, however, to somehow check to see what the current page is and give the corresponding image an "in" state.

I would just change that for each page, however, the navigation is, of course in my header file, so that isn't possible.

Is there any sort of php go around so I can put in an if statement to tell the navigation to keep one clicked in?

Here's the code for the stylesheet:


#products{

height: 20px;
width: 85px;
text-indent: 10000px;
overflow: hidden;
background: url(/images/nav/products.gif) top left no-repeat;
display: block;

}

#products:hover{

background-position: bottom left;

}

and here's the code for the corresponding nav button:

<a href="#" id="products">Home</a>

Thanks for the help

Jesse

www.coasttravelmugs.com (http://www.coasttravelmugs.com)
use the $_SERVER array. $_SERVER['PHP_SELF'] should give what you need.
'PHP_SELF'
The filename of the currently executing script, relative to the document root. For instance, $_SERVER['PHP_SELF'] in a script at the address http://example.com/test.php/foo.bar would be /test.php/foo.bar. The __FILE__ constant contains the full path and filename of the current (i.e. included) file.

If PHP is running as a command-line processor this variable contains the script name since PHP 4.3.0. Previously it was not available.


LG

ray326
05-05-2006, 09:06 PM
Give each page body a unique ID.

SliderNo1
05-05-2006, 10:30 PM
That's exactly what i did with my nav bar. Styled all the buttons with CSS and used an id to denote "thispage" in the nav list -

<li id="thispage"><a href="index.php">Home</a></li>

then created a specific CSS style for #thispage to give a down button effect -

/* special style for link to identify current page */
#thispage a:link, #thispage a:visited,
#thispage a:hover, #thispage a:active {
background-color: #F7E8E1;
color: #800080;
border-left: #5B6058 solid 2px;
border-top: #5B6058 solid 2px;
border-right: #B1B7AE solid 2px;
border-bottom: #B1B7AE solid 2px;
}

obviously change the colours and borders to suit your own site.

Was very easy to do and works just great!