|
|
Simple Template System | ||
Discussion by Miles with 0 Replies.
Last Update: April 22, 2008, 6:30 pm | |||
Hello,
This is my first tutorial at astahost. It covers how to make a simple template system, which I use in some of my software.
To start, we need a page that will be the template itself. For this tutorial, below is a very simple one:
<HEAD>
<TITLE> PHP Template System </TITLE>
</HEAD>
<BODY>
<H1> <?php echo $content; ?> </H1>
</BODY>
</HTML>
Save this as template.html
Next, the php, also very simple:
$content = "Test";
include "template.html";
?>
You'll notice the variables $content contains the content of the page you wish to appear. This coding is simple and can easily be expanded on, for instance, you could use GET to have multiple pages, or have sidebars and add extra variables for them. It's simple coding, but it's not bad either.
This is my first tutorial at astahost. It covers how to make a simple template system, which I use in some of my software.
To start, we need a page that will be the template itself. For this tutorial, below is a very simple one:
CODE
<HTML><HEAD>
<TITLE> PHP Template System </TITLE>
</HEAD>
<BODY>
<H1> <?php echo $content; ?> </H1>
</BODY>
</HTML>
Save this as template.html
Next, the php, also very simple:
CODE
<?php$content = "Test";
include "template.html";
?>
You'll notice the variables $content contains the content of the page you wish to appear. This coding is simple and can easily be expanded on, for instance, you could use GET to have multiple pages, or have sidebars and add extra variables for them. It's simple coding, but it's not bad either.
Tue Apr 22, 2008 Reply New Discussion
Looking For A Reliable Hosting (7)
|
(5) Coding Layouts Coding layouts
|
Index




