The Big Idea
So what is the big idea? There are not may of them:
-
A selection of CMS modules that can be dropped onto the main 'collector template'
-
The system should render valid HTML code to the very place we have dropped it.
-
The system should be very lightweight, fast and need as few system resources as possible
-
It should be easily extendable with new modules and easy-to-write templates
-
It should use friendly URLs like http://oursite.com/site_news_item/123
-
It should have basic AJAX support
-
It should be safe and difficult to hack into
We will have a look at a very simple DIV based layout with a main 'collector template'. Anybody should understand what we are going to build. However, when reading this please note that the snippets will not work as such. We must create the modules and the overall framework. To have a sneak preview of what we will create, feel free to open the element to see the code.
... wait a moment...
As you can see the page contains no PHP code. The executable code resides in the modules we will load on-the-fly. Let's have a look at the funny bits.
The first weirdness is in the head part. The title contains a template variable which defaults to "SkoopCMS" if empty. As simple as that.
The second one one loads the top menu.
Then we have a conditional 'if' structure which simply checks the value of template variable $command and loads a module accordingly. If no match occurs the template makes an educated guess: "This must be the name of a page" and launches a dynamic page module with more or less good luck. More on that later...
And here comes the included sidebar code:
... wait a moment...
Here we have a site news module and two instances of RSS feed reader modules with different RSS sources and different number of items to show. Understood? Good!
But why templates? Why not just PHP?
First of all: an HTML designer find it easier to modify the structure. The only thing we need to instruct him/her about is: "do not touch anything between the curly braces". Or better still give him a short lesson about templates. If he has any brains he will get the idea in minutes. Needless to say we need to document our templates (or at least the way we have made use of CSS in them).
Do not worry: there will be PHP code, good, fast PHP. Every time you change a template it will be compiled to PHP. Moreover, if you learn your template engine well enough you can define a caching time for any view. That will make your dynamic site behave almost like a static one. There are several English words for it, one of them being "speedy", another might be "lightning-fast".
We have written an analysis on the performance page.
Okay. That’s it. Now we must dig into the system define our classes to make it possible to write new CMS modules.