Conclusion
July 28, 2000
An interesting side-effect is that in the handle_xxx function you can use
the parse_it function again to parse externally retrieved data. Say that you
have a <my-include file=..>, that file can also contain new
<my-..> tags if you implement res/include/include.php
as follows:
<?php
function handle_include ($arglist) {
if (($arglist["file"]) && ($f = fopen ($arglist["file"], "r"))) {
$buf = "";
while ($str = fgets ($f, 4096))
$buf .= $str;
fclose ($f);
return parse_it ($buf);
}
return "<!-- include: error opening " . $arglist["file"] . " //-->";
}
?>
Using caching here will probably prove useful if including from external
sites:
<my-include file="http://remote.server.com/foo.my" cache=3600>
This way, the file is only fetched from the remote server once an hour,
for all the other requests the cached entry is used, which is much faster.
-JP
$buf
Building your website with cached dynamic modules
|