Consummo Uses Templates for More Than Just Looks

Utterly PointlessUnequivocally DaftThoroughly AverageModerately ImpressiveBeyond Brilliant Rate this article

As many already know, I’m not a fan of limiting an application to be backward compatible. I am, however, a firm believer of forward compatibility. I believe applications (any product actually) should be prepared for the future. Sure, something new and unexpected will inevitably pop up sooner or later, but that isn’t the point. The point is, preparing for the future will make expanding the application in the future a smoother process. This is why many web applications provide some way (however limited) to change the look and feel of the front-end. With Consummo, I’m taking this one step further.

From my experience, there are two types of template systems. One, although less common, does a great job of being forward compatible. It builds each tag with a class of functions. Here’s an example:

<?php
 function build_paragraph($content){
  $html = new HTML_BUILDER;
  $html->add_tag('p'); // Create paragraph
  $html->add_attr('class','article'); // Set class to 'article'
  $html->add_attr('content',$content); // Add content passed to function
  return $html->return(); // Return content
 }
?>

Ignoring the several possible errors in the code above, it gives a rough example of how this type of template system works. Because it builds each tag based on a class, the entire application can be upgraded to a new HTML specification by changing some variables in a single file. The downside is it requires the user to learn a new, and more complicated, language.

The other template system uses a header, footer, and a couple files for other parts of the system (article, page, etc). This type of system can be found in many web applications (WordPress, PHPBB, etc), but is faced with the problem of upgrading to a new HTML specification. It also makes it more difficult for a user to make templates for it. Sure, they can change the look of one section of the site with just one file, but it doesn’t allow them to fine-tune it as much as it should.

Consummo, on the other hand, allows the use of any HTML specification. In reality, other languages could be used as well. Each web language is placed in its own folder (/cf-models/html-5/ for example) and contains all necessary models to build Consummo. Plugins also use the template system to serve content to the application. This not only allows an easy upgrade to new specifications (or fixes to old standards), but it also allows users to choose a language they are most comfortable with (or prefer). While I would like to use HTML5, others may want to stick with HTML 4.01, and yet others insist upon using XHTML 1.0. Consummo lets the user make the decision!

Tags: , ,

Leave a Reply