View Full Version : A variable changed per page

08-02-2012, 05:33 AM
Hi there guys. It's obvious through the topic title that I'm not really familiar with HTML. I'm a C/C++ and Objective-C programmer actually. I really need to use and learn HTML now though. Dreamweaver's really helping me, but I still need some help.

I want to design a navigation bar with few buttons. Every button has a transparent background. When you hover, it gets brightened (or whatever effect it is), and when you click, the background changes to something else. For example, the main background is blue, clicking changes it to green and of course you're on a different page.

However, I want to set a variable or so, and check the current page so I don't have to write the navigation code at every single page. Is there a way to do so? Must I use php/javascript? If the only way is to use java or php, can someone help as I really suck at both?

08-02-2012, 12:19 PM
Are you talking about highlighting the current page link in some way? I think you are...have a look at this (http://www.search-this.com/2007/06/13/css-current-page-indicator/) which explains how to this with html/css only.

08-04-2012, 07:00 AM
Yea, I know about the selector thing.

A problem is there though. The buttons are actually "images". There's no CSS function to set the src of the image. Some guys talk about the background-image thing, but I don't think that's stable and promising enough.

I guess the only way to solve that would be php or javascript

Another P.S: I've worked about a year with phpBB, so I have some HTML and CSS experience :) Never thought about learning php though as that was before I learnt C.

08-04-2012, 07:50 AM
Hi TheNavigator,

Why isn't background-image stable or promising? It is kind of standard. There is no danger of it being deprecated soon.

Good luck

08-04-2012, 08:54 AM
Okay then netsentry. I'll try that and reply with the result :)

EDIT: Just decided to let it be hard-coded. Thank you guys for your help anyway :)

08-04-2012, 02:08 PM
.nav ul li a:hover {brighten effect}
.nav ul li a:active {background image}
.nav ul li {background}

08-04-2012, 02:18 PM
You have to use a dynamic page/url




<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">
<title>Website Name- <?php echo $_GET['p']; ?> - Slogan!</title>
<link rel="shortcut icon" href="/images/favico.ico" />
<!-- meta -->
<meta name="author" content="--" />
<meta name="keywords" content="--" />
<meta name="description" content="--" />

<!-- styles -->
<link rel="stylesheet" type="text/css" media="screen" href="css/screen.css" />

<!-- scripts -->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>


<!-- start //body -->
<div id="wrapper">
$filename = 'includes/header.php';
if (file_exists($filename)) {
include "$filename";
} else {
echo "The file $filename does not exist";
<div id="page">
<div id="page-bgtop">
<div id="page-bgbtm">
<div id="content">


// This will include your content //

$pages_dir = 'includes'; //pages file dir//

if(isset($_GET['p'])){ $page = $_GET['p'];
if(!strpos($page, '.') && !strpos($page, '/')){
} else {
header ('location: /index.php?p=home&error'); //error page //
} else {
echo "Access Forbidden!";
} else {
<div style="clear: both;">&nbsp;</div>

<?php include("includes/sidebar.php"); ?>

<?php include("includes/footer.php"); ?>

You will create all of your pages in dir "includes"

This is just an example..

NOTE: If you look at the title it will take the name of the current page open and display it..