Home arrow PHP arrow Page 6 - PHP Fast Template

Summary - 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
Many times, when working with smaller projects, taking the time to separate the presentation from logic is like taking the time to ask guests to leave the dinner table each time a new dish is brought from the kitchen to hide where its coming from. Some programmers have said if lines of code are greater than 1000, go ahead and separate the two. There's no question that projects that are going to involve 100% database stored content can benefit from creating HTML templates and parsing data through them with PHP and the FastTemplate class. Remember that there are many tools for separating presentation and logic and the best one for the job is the one that's desired. Make certain you have the right one before the project gets too deep.

Appendix / Notes
When installing PHP4 and FastTemplate, it was necessary to edit a line of code in the FastTemplate class in order for it to work properly.

Within the parse_template function of the class this line was edited:

$template = ereg_replace("\{$key\}","$val","$template");
The curly brackets had not been escaped in the code so the script ignored any variables in the HTML templates.



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

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

PHP ARTICLES

- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- 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...

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: