Home arrow PHP arrow Page 5 - Template-Based Web Development With patTemplate (part 2)

Legal Eagles - PHP

Got the basics down? Well, here's the advanced course - thisarticle demonstrates some of patTemplate's more sophisticated features,including the ability to dynamically show or hide templates, inheritvariables, use loops and conditional branches, and create dynamic,template-based forms and error handlers.

TABLE OF CONTENTS:
  1. Template-Based Web Development With patTemplate (part 2)
  2. Scoping It Down
  3. Speaking In Tongues
  4. Looping The Loop
  5. Legal Eagles
  6. Hide And Seek
  7. Setting Things Right
  8. Fortune Favours The Brave
  9. Running On Empty
  10. Simple Simon
  11. Brain Dump
  12. A Well-Formed Example
  13. Crash Bang Boom
  14. Endgame
By: Team Melonfire, (c) Melonfire
Rating: starstarstarstarstar / 10
June 19, 2002

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement
You can source an external file into your template via the "src" and "parse" template attributes. Let's suppose I have a copyright notice, stored in the file "copyright.txt", which looks like this:


Everything here is copyright Melonfire, 2002. Be good. We have lawyers.
I can source this file by attaching the "src" attribute to a template,

<patTemplate:tmpl name="copyright" src="copyright.txt" />
and tell the engine whether or not to parse the sourced file for template variables with the additional "parse" attribute.

<patTemplate:tmpl name="copyright" src="copyright.txt" parse="off" />
Once that's done, I can call this template from within another template, like this:

<patTemplate:tmpl name="main"> <html> <head> <basefont face="Arial"> </head> <body> This is my Web site. It has lots of interesting stuff on it that you might want to use for your own nefarious purposes. But before you do, read the notice at the bottom of this page. <p>&nbsp;<p> <hr> <patTemplate:link src="copyright" /> </body> </html> </patTemplate:tmpl>
And now, when I parse and display the "main" template, the external file "copyright.txt" will be read and incorporated in the final output by the template engine. Here's what it looks like:



 
 
>>> More PHP Articles          >>> More By Team Melonfire, (c) Melonfire
 

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 3 - Follow our Sitemap

Dev Shed Tutorial Topics: