Building your website with cached dynamic modules
July 28, 2000
|
In today's web-world the emphasis is on load speed and easy maintenance.
Learn how to construct a website on the fly using dynamic modules
which can be cached for improved performance.
|
JP
In this article I will show how to use a modular system to create a website
that is constructed on the fly using dynamic modules, which for performance
sake can be cached if you want. Each module is a php script on its own,
returning html data to be included in the final html page.
Overview
- php scripted modules that implement functionality (e.g. a style
definition, menu or discussion board)
- a parser that can construct the html page by reading input files,
determining which modules to call and then combine output of the modules
- files with specific extension (say .my) that specify html + calling
tags for each module
Walkthrough
To demonstrate how it works, let's see a file called hello.my:
<title>Hello world</title>
<my-style name=test>
hello world
If a request is being made for index.my, the webserver redirects
this request to the php parser, which just scans for <my- .. >
tags. It finds the 'style' tag, and looks for the module style.php
in its module directory.
The file style.php is included and the function
handle_style ($arglist) is called, where $arglist is an
associative array of all specified parameters to the tag (here:
<?php $arglist[name] =
"test"; ?>
).
The handle_style function must return a string containing html. How
the module determines the html doesn't concern the system. Say, the
handle_style module returns <font face=Arial size=2 color=yellow>
and the parser includes this in the final html.
Contents:
The Final HTML
Security
The parse_it function
$buf
Conclusion
Building your website with cached dynamic modules
The Final HTML
|