UNIX Systems Administrator (IL)
Next Step Systems
US-IL-Chicago

Justtechjobs.com Post A Job | Post A Resume

PHP Templates: Revisited
To finally grasp the whole idea of this parsing concept let's go straight on the script. I've coded the scripts under a class. With this you only have to import this class then use its function to parse your HTML files. To get a detailed explanation of what is this all about read the article of Wee Lep "PHP-HTML Templates: A New Working Relationship", which can be accessed here.. The concept of this parsing was taken from his article. The only reason in which this article was put into action was because Wee Lep didn't provide a running or working example of his concept, a problem which I also encountered when I tried to apply his scripts into my application. Taken from an extensive, serious research of various code around the net, I was able to generate these scripts which have a concept similar to what Wee Lep wanted to explain. Thus if you're into concept and discussion I suggest you read Wee Lep article as this article is only a working example of his idea. This article is code-centric, more on application. Probably, at the end of this article you'll be able to parse your HTML files and replace it with your desired values stored in an array. This article consisted of four topics of discussion of the templates: how to load templates, how to replace statics, how to replace dynamics. This template has been applied to my phpmylibrary.sourceforge.net application.
The Templates
To start our scripting lets first take a look at the example HTML template we would like parse. This kind of template can be edited from any HTML editor like Dreamweaver, MS Frontpage, etc., thus eliminating the confusion of webpage designer and webpage programmer and their fields of expertise. Designer will be able to freely create whatever design technique he/she wanted to make without disturbing the code of the programmer, on the other hand, the programmer simply stores their result in an array which will be encoded on HTML template created by the designer. This completely divides the world of the designer and the programmer and would probably help each other in enhancing much of their talent.
This is the desired output.


+-------------------------+-----------------------+-------------------+
| Polerio and PHPBUILDER  | Article about parsing | Some Fixed Values |
+-------------------------+-----------------------+-------------------+

	+----------+-------------------------+------------------+
	|   Date   |         Title           |      Author      |
	+----------+-------------------------+------------------+
	| 09/28/02 | Parsing Made Simple . . | Juan Tamad       |
	+----------+-------------------------+------------------+
	| 09/30/02 | PHP Templates: Revi. .  | Polerio Babao    |
	+----------+-------------------------+------------------+
	|    .     |            .            |        .         |
	+----------+-------------------------+------------------+
	|    .     |            .            |        .         |
	+----------+-------------------------+------------------+
	|    .     |            .            |        .         |
	+----------+-------------------------+------------------+

This is the HTML Template, template.html

<?php

<html><head><title></title></head>
<
body>
<
table><tr>
<
td><!--%ModuleTitle%--></td>
<
td><!--%SomeComment%--></td>
<
td><!--%FixedValues%-->
</
td></tr></table>
<
br><br>
!--%
00_BEGIN_NO_MESSAGES%-->
    <!--%
97_BEGIN_NO_MESSAGES%-->
    <
table border="1">
    <
tr><td>Date</td><td>Title</td><td>Author</td></tr>
    <!--%
9a_BEGIN_MESSAGE_LIST%-->
    <!--%
9a_ML_LOOPBEGIN%-->
    <
tr><td><!--%9adate_____%--></td><td><!--%9atitle____%--></td><td><!--%9aauthor___%--></td></tr>
    <!--%
9a_ML_LOOPEND%-->
    </
table>
    <!--%
9a_END_MESSAGE_LIST%-->
    <!--%
97_END_NO_MESSAGES%-->
<!--%
00_END_NO_MESSAGES%-->
</
body></html>

?>
Next Page


Comments:
Constuctive Critisismscottybwoy08/30/07 05:50
PHP Programming,- text-based gameScott D05/02/07 17:28
Improvement to access to SubsectionsShai Lipkovich06/11/05 14:57
Contact php File to replace Mail@Peter Brennan02/16/05 03:19
Template helpAisha D02/04/05 12:19
All smarty isDumbass10/02/04 22:01
Templates live where you dare not treadBenjamin Smith04/24/04 03:10
agreed:RE: Templates are DEAD! Long live PHP!Roy Robin12/19/03 13:52
RE: Templates are DEAD! Long live PHP!Hobbit06/08/03 16:19
TemplateTamerDavorin Rusevljan01/05/03 10:17
RE: Templates are DEAD! Long live PHP!L long12/17/02 16:32
Introducing {PHPTMPL}Geraud Krawezik11/18/02 07:59
RE: Templates are DEAD! Long live PHP!Sonic_Molson11/15/02 22:04
RE: Templates are DEAD! Long live PHP!Patrick Fitzgerald11/03/02 12:57
Wow... Needs lots of improvementeruanno10/22/02 09:52
RE: Templates are DEAD! Long live PHP!Michael Sinclair10/14/02 15:07
RE: Templates are DEAD! Long live PHP!Harry Fuecks10/09/02 06:05
This is what I would doJoe10/07/02 02:33
RE: Templates are DEAD! Long live PHP!Michael Sinclair10/06/02 08:31
RE: Templates are DEAD! Long live PHP!haj10/02/02 02:44
RE: Whats wrong with FastTemplate or phplibhaj10/02/02 02:36
RE: Templates are DEAD! Long live PHP!M. Thornton09/30/02 14:55
RE: Templates are DEAD! Long live PHP!Harry Fuecks09/29/02 08:13
RE: Templates are DEAD! Long live PHP!bigSys09/28/02 11:48
RE: Templates are DEAD! Long live PHP!c-dawg09/27/02 19:35
PHP replication of Zope and JSP for templatigMichael Glazer09/27/02 17:49
RE: Don't be too criticalBDKR09/27/02 11:06
RE: Templates are DEAD! Long live PHP!Adalberto09/27/02 10:54
RE: NEED HELP URGENTLY, PLEASEadd php project09/25/02 05:49
NEED HELP URGENTLY, PLEASEEddieson09/24/02 12:00
RE: Templates are DEAD! Long live PHP!dotwebbie09/23/02 11:40
The best template engine is SmartyOskars09/21/02 16:32
patTemplateMitchell Landry09/21/02 02:14
RE: Templates are DEAD! Long live PHP!Harry Fuecks09/20/02 06:45
RE: Whats wrong with FastTemplate or phplibZpiff09/20/02 04:32
RE: Templates are DEAD! Long live PHP!Yuriy Horobey09/19/02 02:31
Templates are DEAD! Long live PHP!Harry Fuecks09/18/02 12:21
RE: Whats wrong with FastTemplate or phplibanimosity09/18/02 12:19
Don't be too criticalJason09/18/02 09:21
RE: why notTom Anderson09/16/02 12:06
Uhm... ya.. ok...Vincent09/15/02 08:38
one more thingAivar Annamaa09/15/02 04:34
ComplexTemplateAivar Annamaa09/15/02 03:55
RE: why notClaudio Bustos09/14/02 16:26
RE: why notkybosh09/13/02 19:54
why notPhynias09/13/02 11:22
Whats wrong with FastTemplate or phplibZpiff09/11/02 08:24
why not simply use patTemplate or alike?NightOwl09/11/02 02:41
just use vlibTemplateKelvin Jones09/10/02 04:31
Ignore this article: save brain cells.Tom Anderson09/09/02 15:23
 

If you are looking for help, please post on the appropriate forum here. Your questions will be answered much more quickly.

Add A Comment:

Name:

Email:

Subject:

Message:

To reduce spam posts, messages are now manually approved

You are not [logged in]. That means your account will not get credit for this post.