Post by D'lo on Aug 5, 2005 0:58:55 GMT -5
This is a small tutorial on changing layouts easily with PHP. I learned this from Day Dream Graphics. All you need for this is:
- any HTML editor
This kind of php is most useful when the layout it is being used for is a tables/div layer layout, such as mine.
_________________________________________________
The Tutorial
First, create two new files with your HTML editor. The extensions for these files can be .txt or even .php. We'll be using .php for this tutorial. Name the first file 'header.php' and the second 'footer.php'. If you already have done the coding for the layout in a separate file, it would be very useful if you'd open that file also. If you haven't, just code the first part of the coding of the layout up to wherever the content starts. We'll use my site's header.php as an example:
As you can see, I stopped coding the page right before I started typing whatever the content ahead was to be. This, incidentally, is the end of the 'header.php'.
In the 'footer.php', the rest of the coding (minus the content) should be left. Let's take a look at my site's 'footer.php' for a better look:
In the 'footer.php' file, the coding for everything after the content was present only. Now that you have your two main files, all you need is the simple code to allow you to change a layout only by changing the header and footer:
I recommend that you start a new file called 'blank.php' and copy and paste this code into it so that you can use it for any future pages you may create later. The content should be anywhere between those two lines so that you only need to change those two files to change a layout. The 'content' files should look something like this:
There. Any questions? Feel free to post them and I'll answer them asap.
Note: To use a php-created layout, your server must allow php - if it doesn't, you can download something and upload it to your server, which will allow php. However, I don't have to give you the link, as you can search for it yourself. No offense, but people should do their own work.
- any HTML editor
This kind of php is most useful when the layout it is being used for is a tables/div layer layout, such as mine.
_________________________________________________
The Tutorial
First, create two new files with your HTML editor. The extensions for these files can be .txt or even .php. We'll be using .php for this tutorial. Name the first file 'header.php' and the second 'footer.php'. If you already have done the coding for the layout in a separate file, it would be very useful if you'd open that file also. If you haven't, just code the first part of the coding of the layout up to wherever the content starts. We'll use my site's header.php as an example:
<html>
<head>
<title>Subarashii Dream | version 10.0 .:Kirari Sailor:.</title>
<link href="css.css" rel="stylesheet" type="text/css">
</head>
<body>
<table width="" cellpadding="0" cellspacing="0" align="left">
<tr>
<td><img src="image/left.jpg"></td>
</tr>
</table>
<table width="200" cellpadding="0" cellspacing="0" align="left">
<tr>
<td><img src="image/navtop.jpg"></td>
</tr>
<tr>
<td><a href="http://users.tpg.com.au/leighjon/ck/CK2003BSMS.htm"><img src="image/link/moonieawards05.gif" border="0"><br>
Vote for me!</a><p>
<!-- Start FastOnlineUsers.com -->
<a href="http://www.fastonlineusers.com"><script src=http://fastonlineusers.com/online.php?d=www.subarashiidrean.net/footer.php></script> online</a>
<!-- End FastOnlineUsers.com --><p>
<b>Navigation</b><br>
<a href="main.php">Home</a><br>
<a href="e-mail.php">E-mail</a><br>
<a href="http://subarashiidream.proboards60.com">Forums</a><p>
<b>Media</b><br>
<a href="info.php">PGSM Articles</a><br>
<a href="writing.php">Writings</a><br>
<a href="mv.php">Music Videos</a><br>
<a href="fanart.php">Fanart</a><p>
<b>Site</b><br>
<a href="domain.php">Domain</a><br>
<a href="credit.php">Credits</a><br>
<a href="policy.php">Policies</a><br>
<a href="thank.php">Thank You's</a><br>
<a href="link.php">Linkage</a><br>
<a href="joined.php">Joined</a><br>
<a href="pastlayout.php">Past Layouts</a><br>
<a href="old.php">Old Updates</a><p>
<b>Me and You</b><br>
<a href="award.php">Awards</a><br>
<a href="awardyou.php">Awards for You</a><br>
<a href="gift.php">Gifts</a><p>
<b>Graphics</b><br>
<a href="banner.php">Banners</a><br>
<a href="avatar.php">Avatars</a><br>
<a href="layout.php">Free Layouts</a><p>
Site and Layout © <a href="mailto: dhampton@subarashiidream.net">Mars</a><br>
Image © <a href="http://www.three-lights.net">Three Lights [dot] net</a><br>
Brushes © <a href="http://www.angelic-trust.net">Angelic Trust</a><br>
Font © <a href="http://www.beautifulfonts.com">Beautiful Fonts</a></td>
</tr>
</table>
<table width="" cellpadding="0" cellspacing="0" align="left">
<tr>
<td><img src="image/center.jpg"></td>
</tr>
</table>
<table width="695" cellpadding="0" cellspacing="0" align="left">
<tr>
<td><img src="image/main.jpg"></td>
</tr>
<tr>
<td>
As you can see, I stopped coding the page right before I started typing whatever the content ahead was to be. This, incidentally, is the end of the 'header.php'.
In the 'footer.php', the rest of the coding (minus the content) should be left. Let's take a look at my site's 'footer.php' for a better look:
</td>
</tr>
</table>
<table width="" cellpadding="0" cellspacing="0" align="left">
<tr>
<td><img src="image/right.jpg"></td>
</tr>
</table>
</body>
</html>
In the 'footer.php' file, the coding for everything after the content was present only. Now that you have your two main files, all you need is the simple code to allow you to change a layout only by changing the header and footer:
<? include ('header.php') ?>
<? include ('footer.php') ?>
I recommend that you start a new file called 'blank.php' and copy and paste this code into it so that you can use it for any future pages you may create later. The content should be anywhere between those two lines so that you only need to change those two files to change a layout. The 'content' files should look something like this:
<? include ('header.php') ?>
This is my site. It's using a simple php code that allows me to change layouts rather easily, specifically my tables and div layers layouts!
<? include ('footer.php') ?>
There. Any questions? Feel free to post them and I'll answer them asap.
Note: To use a php-created layout, your server must allow php - if it doesn't, you can download something and upload it to your server, which will allow php. However, I don't have to give you the link, as you can search for it yourself. No offense, but people should do their own work.