Preface
Some dull history (for old geezers)
This tutorial presents some of the ideas I have come up with during my years of development. I have written software since 1982 but only started my web career in 2001. I was writing Java then and hardly knew any HTML . After writing a few applets and a couple of servlets I knew some basic ideas. However, in 2001 I still hired a Perl programmer and only learned Perl in 2002.
Perl felt like going back 20 years in time. It was a horrible language even when using kind-of object-oriented libraries. PHP - the next step - was only slightly more comfortable. All tutorials, libraries and frameworks were appalling and basically vomitted out HTML exactly the the Perl ones did. I was missing an abstraction level I had been used to in desktop environments. Echoing HTML in between the PHP lines of code felt very archaic.
Then I came across the Smarty engine. It filled a good deal of the abstraction hole for small scale web development. Seeing its benefits I presented it to an old Java developer who hated PHP because "it lacked a concept of an application". After four weeks he called me and said that what I had given him was incredible. In six weeks he had already written a CMS using PHP... and Smarty.
In 2003 I needed to write a site that with adminstration for two dozen database tables plus the public listings. I borrowed some concepts from my 15 years of Clarion database experience and created classes
Browse, Edit and Update and wrote some generic templates. A site that would have taken me three months was finished in three weeks. Additionally I had a set of general-purpose database classes and templates! Six months later we had version 2 of the framework running and a year from that more than 200 applications (mainly for call centres) had been written already.
In 2009 I took the task of cleaning the code and the templates in the base classes. At the same time I got the idea of writing another template based application framework for content management based on work I did on a project three years earlier. The target was to create an object oriented, very clean and simple but also an easily extendable framework. It needed a Smarty plug-in and the Smarty library, of course.
The Collector Template
The idea was to create an application template that would contain generic Smarty plug-in directives or statements. The task of the statements was to instruct the Smarty instance to load and initialize respective instances of CMS module objects, feed them with parameters and ask them to return valid HTML. The main template would simply be a 'collector' of modules. The idea proved to be a very productive one and creating new CMS modules became very, very easy indeed.
This tutorial tries to present the process I went through, keeping things on a simple level but giving ideas for readers. It is to be noted as well that this very site has been built using the same set of tools we will build here.
The Future
There will be more modules and more functionality in the future. Some more modern techniques like Ajax will be used. If you wish to comment on the ideas presented here or - even better - you have an interesting project or job to offer then do not hesitate to contact me.
I dedicate this tutorial to my late cat who met his fate in the form of a lynx, his big wild cousin, on a warm
and cosy summer morning just a couple of weeks before the day I started to write this
markku.niskanen@gmail.com
Calendar
Site News
BBC Scotland
The validity of this site may vary while it is being
developed.
Feel free to test it, though :)