Home arrow PHP arrow Page 2 - PHP Fast Template

Assigning templates to objects - PHP

Why separate presentation from logic?The simple answer to the question is, "It keeps things simple". If presentation wasn't separated from logic around your house, you'd have to be an electrician to replace light-switch covers. The same goes for large-scale web applications. Graphic designers shouldn't need to be software engineers in order to update the fonts in a web page. Separating logic from presentation makes that possible.

TABLE OF CONTENTS:
  1. PHP Fast Template
  2. Assigning templates to objects
  3. Assigning variables to FastTemplate objects
  4. MySQL Data parsed through FastTemplates
  5. Multiple templates: Rows of data into a table
  6. Summary
By: Ian Felton
Rating: starstarstarstarstar / 27
July 02, 2001

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement
Once the class file has been included, HTML templates can be assigned to an array for use throughout the script.

First, a new template object must be instantiated like this:

$tpl = new FastTemplate("../templates");
The path in quotes points to the location of the HTML templates being used. This will vary depending upon personal preferences.

Once the instance exists, external HTML templates are assigned to variables in the array like this:

$tpl->define(array( "index_tpl" => "some_html_template.tpl" ));
In the above code, "index_tpl" is arbitrary. In fact many solutions involve assigning many templates to variables within one instance.

An example of multiple templates declared for use in a script:

$tpl->define(array( "index_tpl" => "some_html_template.tpl", "sub_idx_tpl" => "another_html_template.tpl", "last_idx_tpl" => "last_html_template.tpl" ));




 
 
>>> More PHP Articles          >>> More By Ian Felton
 

blog comments powered by Disqus
   

PHP ARTICLES

- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...
- PHP: Building Concrete Validators
- Sanitizing Input with PHP
- Executing Shell Commands with PHP
- Handling File Data with PHP
- File Security and Resources with PHP
- ArrayObject PHP Class Examples
- ArrayObject PHP Class: An Introduction
- Getting File System Data with PHP
- PHP Tools for Working with the File and Oper...
- Working with the File and Operating System w...
- PHP Proxy Patterns: Completing a Blog


© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 7 - Follow our Sitemap

Dev Shed Tutorial Topics: