The Neopian Bay - Neopets Fansite; Guides, Graphics and Giveaways. Arid Seas Plug - Free Advertising Arid Photos  - Free Stock Photos Arid Seas Topsites - Site Analytics and Free Backlinks SEO Panel  - Free Submissions


Signs

Avatars & Forum Signatures

Resources

Generators

Make Your Own Layouts

Backgrounds

Layouts/Templates

Facebook Banners

Graphic Design Tutorials

Webmaster Tutorials

Coding Tutorials & Snippets

Submit!


Subdomain Hosting

Cutenews Hosting

SEO Panel - Free Submissions

Credits

Affiliates

Terms

Link to Us

Contact Us

The Neopian Bay

Arid Plug - Plugboard

Arid Seas Stockphotos

Best Webhosts - 2012

Arid Seas Topsites

How to use PHP Includes in Layouts

PHP includes are always the most effective way of publishing a layout. First off, you're able to change the layout whenever you want to; and the only alternative to that would be iFrames, unless you want to change every single page on the site when you add a new link or change the color of the font, that will simply make updating your site a drag.
A few notices before we get started:

  • PHP is much better then iFrame layouts as you can open in a new tab, and the layout is on every page, so search engines are more effective.
  • Your webhost must support .php files and, of course, you must have direct access to your directories (this doesn't work with site editors). So, if you're using a free host, you may need to change hosts.
  • If you'd like to validate your website, you need to have a CSS stylesheet embedded externally on every page
  • Again, of course, if you want to be optimized for search engines; you will need to make meta tags for every page.
First off, you need to figure out what kind of layout you have, and where your contant actually goes.

<div class="overlay"> <div class="innerbox" id="innerbox1"> This is a div layout. Usually the content would go right here. If the background is an image, it will most likely be a 'div' or a 'div overlay' layout like this one is. This also could be where your iFrame is located. </div>

<table border="0"> <tr> <td> This is a table layout; your content could go here, or there could be multiple columns (one for sidebars, etc). You will need to find the spot where your content is located in the table. This also could be where your iFrame is located. </td> </tr> </table>

Now create two new files, named part1.php and part2.php
In part1.php -- add the first part of your layout (everything above of the content in your code), such as this example:
<table border="0"> <tr> <td>


and in part2.php -- you need to add everything below the content.
Now comes the fun (time consuming) part. Find where part1.php and part2.php are. If they are in the same directory as your index.php file, it'd be http://www.example.com/part1.php and http://www.example.com/part2.php (replacing example.com with your domain, of course)
At the top of every page, add this code:

<?php include(" PUT THE URL OF PART 1 HERE "); ?>

and at the bottom of each page, add this:

<?php include (" PUT THE URL OF PART 2 HERE "); ?>