Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

JackT06

macrumors 6502
Original poster
Jul 24, 2009
293
0
What i would like to happen is that everytime i change something on one of my html pages on the banners it changes it to all rather than me having to go through all the pages and change them.

Many Thanks

The pictures show how my website is at the moment
Picture1-1.png
[/IMG]
 
What you want can be accomplished (only) with PHP. You create an HTML file with just the header, and then, using a PHP function (if you're interested, require_once('filename');), you link it into the final web site. There might be a better function, I can't say at the moment. Wordpress uses include_header();, and so on while creating its index.php, but I don't know how that works.
 
would the idea of pannels work because the only bit i really want to change is the bit in the middle. And then on my bar across the top put the link to change the panell?
 
If your using a specific program it depends on what your using.

For pure webcoding you can create utilize something as the above posted stated and use a PHP include function to dynamically add a file to a page so that once you change the main page it trickles down to the others.
 
If your using a specific program it depends on what your using.

For pure webcoding you can create utilize something as the above posted stated and use a PHP include function to dynamically add a file to a page so that once you change the main page it trickles down to the others.

Well at the moment im using textmate doing HTML
 
Easy way I have found is create a seperate file:

banner.php and add your banner code to it as a <div>

Than on all your webpages reference that file using PHP include statement:

http://www.w3schools.com/PHP/php_includes.asp

PHP:
<?php include("header.php"); ?>

Than once you change the banner.php file all the subsequent pages will reference those changes dynamically.
 
Let me give you a sample:

banner.htm
Code:
<div>
<img src="image.png" alt="Image" />
</div>

index.php
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>TITLE HERE</title>
<link href="stylesheet.css" rel="stylesheet" type="text/css" media="all" />
</head>
<body>
<?php require_once("banner.htm"); ?>

//The rest of your code goes here

</body>
</html>

page2.php
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>TITLE HERE</title>
<link href="stylesheet.css" rel="stylesheet" type="text/css" media="all" />
</head>
<body>
<?php require_once("banner.htm"); ?>

//The rest of your code goes here

</body>
</html>
 
Let me give you a sample:

banner.htm
Code:
<div>
<img src="image.png" alt="Image" />
</div>

index.php
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>TITLE HERE</title>
<link href="stylesheet.css" rel="stylesheet" type="text/css" media="all" />
</head>
<body>
<?php require_once("banner.htm"); ?>

//The rest of your code goes here

</body>
</html>

page2.php
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>TITLE HERE</title>
<link href="stylesheet.css" rel="stylesheet" type="text/css" media="all" />
</head>
<body>
<?php require_once("banner.htm"); ?>

//The rest of your code goes here

</body>
</html>


Sorry but i have never used a .php what do i do with them?
 
If your page is index.htm, and you plan to use PHP in it, you'll have to rename it to index.php. It tells the browser the page uses PHP scripting.

But... why don't you try it yourself?
 
As long as your sever is setup to run PHP scripts (most remote hosting will). All you need to do is make sure your webpages are named

XYZ.php and not XYZ.htm

Then include the necessary script on the page. The example above is a good one.
 
As long as your sever is setup to run PHP scripts (most remote hosting will). All you need to do is make sure your webpages are named

XYZ.php and not XYZ.htm

Then include the necessary script on the page. The example above is a good one.


Does that mean i can only view it once i have uploaded it to my host?

unlike HTML where you can just double click on it?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.