Open Browser, Insert Template

Like most database-driven systems, the content management system I use for my web sites, Conversant, is a template-based system. This means that any time someone brings up a page in this site, there’s a pre-defined template, and Conversant sort of fills in the blanks based on the type of page being requested and a variety of other factors.

From my experience, templates are both a boon and a real pain-in-the-butt. On the one hand, you can do a lot of powerful things, especially when templates are combined with the sort of conditional macros that Conversant has. Depending on a number of different conditions, for example, there are several different possible version of pages that people might see. Members of this site see a slightly different version than non-members. Most pages have a printer friendly version, and there are different versions served up to search engines and other robots.

Anyway, in May 2001, Macrobyte added an InsertTemplate macro, and at the time I really did not pay much attention because I had no idea what I would use it for. As my sites have become a lot more complex and began adding features over the past several months, however, it has become a life saver.

To put it simply, the InsertTemplate macro lets me break down the template itself into a bunch of logical sub-templates.

For example, rather than have HTML markup for the header part of each page, I have a separate template called (oddly enough) “Header.” In the default template for this site is a macro that says InsertTemplate name=”Header”. Now the “Header” might seem like a simple matter, but in my case the header area is actually pretty complex with all sorts of options, especially related to Javascript, that have to be checked. It is a lot easier for me to deal with this sort of thing when it is separated into smaller chunks.

In effect what it allows me to do is separate content areas of the template, such as the header information or how page content will be presented, away from the basic shell of tables and rows in which the information is contained.

Now I would not even think of doing this if it didn’t meet my basic criteria — it is extremely fast. In fact, in some cases I have three levels deep worth of templates, and it processes all of this extremely fast.

More importantly, templates can be used across subsites. For example, there are four web sites under this domain. There is,,, and, which are all distinct and separate sites. But I can define a template in my site and then insert it in each of the other sites. So, for example, if I wanted to I could make the default template for any of the other sites be a single line InsertTemplate Name=”default” conversation=”brian”.

Very nice and very powerful.

Leave a Reply