PHP Classes
elePHPant
Icontem

Template Handler: Template handler class to separate HTML from code

Recommend this page to a friend!
  Info   View files View files (2)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2003-11-20 (12 years ago) RSS 2.0 feedStarStarStar 41%Total: 1,557 This week: 1All time: 2,450 This week: 1,047Up
Version License Categories
template_handler 1.0.0Freely DistributableTemplates
Description Author

The template handler class is an efficient way of separating HTML from your PHP code.

This class works on a simple bases of setting template "objects" that are contained within the template file. For instance:

Within a template, define an object this way: {content} .

Then, use $template->setObject('content',$content); to replace the {content} tag with the $content variable.

Objects can be set multiple times within the same script with each "setObject" content appending to the previous. Additionally, the template can also contain PHP code, and this will be correctly evaluated and displayed.

For more detailed explantaion view README.TXT file.

Picture of Rob Thomson
Name: Rob Thomson <contact>
Classes: 1 package by
Country: United Kingdom United Kingdom

Details
#################################################
Template Handler Class
#################################################

The template_handler class is a simple class designed to
assist the developer in wring PHP code, without all the issues
related to embeding HTML in the code.

The class works on a simple principle.  

-  Create an HTML page, and wherever you want 
   dynamic content to be inserted on the page insert
   a 'tag'  i.e:  {content}
   
-  Using the template handler, open the template,
   and set the objects
   
- display the template


=======================================
	sample code
=======================================

<?

# load the new template template
$template = new template_handler();
$template->setBaseDir("templates/");
$template->setTemplate("template.htm");

$template->setObject('content','This is the content');

print $template->Retrieve();

?>


===================================
	sample template
===================================

<html>
<body>
<hr>
{content}
</body>
</html>

-	
  Files folder image Files  
File Role Description
Accessible without login Plain text file README.TXT Doc. Readme File
Plain text file template_handler.php Class Main Class

 Version Control Unique User Downloads Download Rankings  
 0%
Total:1,557
This week:1
All time:2,450
This week:1,047Up
 User Ratings  
 
 All time
Utility:59%StarStarStar
Consistency:68%StarStarStarStar
Documentation:53%StarStarStar
Examples:-
Tests:-
Videos:-
Overall:41%StarStarStar
Rank:2598