Stuffing content into a web page - easy maintainance
Archive - Originally posted on "The Horse's Mouth" - 2007-08-09 06:15:57 - Graham Ellis
All the pages on the main section of this web site are generated by some sort of program - a Perl script that we call "mksite" for page which are essentially static and are generated in batches from a template each time we do an update, and PHP scripts for the more dynamic pages ... although actually it's rather more complex than that in that the Perl script generates PHP (and, yes, it is great fun to protect the $characters needed by PHP from the Perl and vice versa - I'm forever asking myself "is this to be expanded at build time or display time" when I work on this code!).
Before you ask - yes it is more complex than it needs to be; that's a result of the history of its development rather than any current design system. Never the less, it does work efficiently - for the most part, data and templates appear only once, so that a single change (once I find where to make it) will ripple right through the site.
The fashion is to call the whole thing a "Content Management System" - which it is - or a "Templating System" - which it also is. Not developed with those things in mind, but none the worse for that. And everywhere we want to insert content in a template, we use a place holder. For example: "This %topic% course starts on %date%" will appear in the original of the pages we maintain, but that will be filled in by the scripts an either level (Perl or PHP) to give something like "This Perl Programming course starts on 20th August".
I commonly used the placeholder %stuff% for the main content of a page that's to be cut in ... and I was most amused to learn from our student Sam on Tuesday that she also used "stuff" as a main variable name quite often - "a magnificent word" as she described it!