Template-Based Web Development With patTemplate (part 2) - Legal Eagles
(Page 5 of 14 )
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> <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:

Next: Hide And Seek >>
More PHP Articles
More By Team Melonfire, (c) Melonfire