Jump to content


PHP Template


3 replies to this topic

#1 lol89

    Young Padawan

  • Members
  • Pip
  • 9 posts

Posted 04 October 2009 - 10:22 PM

hi, how i can make simple php template so i need system where i have header and footer then i can change environment (home or what will be)

#2 Demonslay

    P2L Jedi

  • Members
  • PipPipPip
  • 970 posts
  • Gender:Male
  • Location:A strange world where water falls out of the sky... for no reason.
  • Interests:Graphic Design, Coding, Splinter Cell, Cats

Posted 04 October 2009 - 10:30 PM

Well, this is quite a broad subject that a simple search can give you alot of tutorials on. Most people use frameworks that are built for using templates, such as a content management system (PHPBB and WordPress come to mind).

Here's a most basic 'technically' a template format.

header.php
<h1>I am the header, hear me roar!</h1>

footer.php
<p>I'm the footer, at the end of the page</p>

page.php
<?php include('header.php'); ?>
<p>This is my page, and I can alter it how I want. The header and footer are independent and can be altered separately, and will not have to be changed on every single page of the site!</p>
<?php include('footer.php'); ?>

page2.php
<?php include('header.php'); ?>
<p>See I'm a second page, and changing the header or footer will reflect a change on me too! You won't have to manually edit my header or footer on every page because you changed it from one location that I am pulling it from!</p>
<?php include('footer.php'); ?>

Basically that's all that really happens, but full on template systems have options for parsing certain tags and adding your own things to them. Take a look at PHPBB's template system and feel free to be amazed at its complexity. Or any forum software really.

#3 lol89

    Young Padawan

  • Members
  • Pip
  • 9 posts

Posted 05 October 2009 - 06:20 AM

thx man :)

#4 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 05 October 2009 - 10:19 AM

If you decide to develop something a little more complex than that, you should take a look around the p2l tutorials:
http://www.pixel2life.com/tutorials/php_co..._and_templates/





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users