The heart and soul of the iTemplate system is the PLUGINS.
PLUGINS are simply a means of mating your program output to your template. We do this by using special comment tags ("PLUGIN Tags") as triggers. When the iTemplate system sees a PLUGIN Tag in your template, it replaces it with output from your program that matches.
This can happen in 2 ways:
A matching function
A global variable ($OUTPUT)
Here's a bit of code to illustrate ...
default.txt Page Layout
<html>
<head>
<title><!-- PLUGIN:TITLE --></title>
</head>
<body>
<div style='background:silver;padding:8px'>
<!-- PLUGIN:MENU -->
</div>
<div style='padding:10px'>
<!-- PLUGIN:BODY -->
</div>
</body>
</html>
application.inc.php -- a php file that your
program includes, which does all of the thinking
<?php
function menu() {
return "cookie crumb menu ... "
}
function body() {
// Assume this function does a ton
// of work and creates some html at the
// end.
return "
<table>
... a whole mess of html
</table>
";
}
?>
What's happening here is this (reference the "Overview" Page, please). After your program creates the tmeplate object, when it calls the "parse" method, it'll read in a file that looks like the default.txt that we show in the below example.
The parse method finds 3 plguins: TITLE, MENU, BODY
It then looks for functions that match those plugin names in your source code. (These are not case sensitive, by the way). In our example here, we have 2 obvious matches, one for MENU and one for BODY. These functions RETURN their HTML instead of echo'ing it out.
Notice that the menu plugin set a global variable $OUTPUT with some generated stuff. Since there's not a "title" function in this program, the template system falls back to trying to find a key in the global variable $OUTPUT instead.
When this program finishes running, all 3 of those comment tags will be replaced by HTML that the program generated when asked for by the template.
Note that plugins, both internal and custom can also accept pamameters ... this feature is not discussed here, but only in the actual program documentation.
As a programmer, all you have to do is this ...
Create templates with plugin tags that match up to functions of the same name. Those functions will then output their HTML to your template automagically where the plugin tags are.
This help file was created with an unregistered evaluation copy of Help & Manual. © EC Software. All rights reserved. This message will not appear if you compile this help file with the registered version of Help & Manual.