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.

  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


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
escort Bursa Bursa escort Antalya eskort


- 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: