Bricolage Templates

Using a content management system doesn't mean the pages on your Web site all have to look alike. Create a custom template for each section.
Creating Templates

So far, we have looked only at existing templates. It's quite easy to create a new template, though. Simply go to the Template menu and click on New Template. You should see a screen that looks like the one shown in Figure 3, asking you to indicate the output channel and category to which your template should apply. Click on Next, and you are asked for the element type to which your template should apply.

Figure 3. Selecting the Output Channel and Category for a New Template

The category-channel-element combination must be unique. You therefore can have multiple templates for an output channel, for a category or for a particular element. But for story elements in the Web output channel in the root (/) category, there can be only one template. If you try to violate this uniqueness constraint, Bricolage issues a warning, telling you that there already is a template for that combination. There are several solutions to this problem; one is to create a new element type, another is to create a new category and still another is to modify the existing template for that combination. The best course of action depends on your specific goals.

I'm going to create a new template for columns within the tofu category, which is represented as /tofu/ in Bricolage. Once I click the Create button, I'm presented with an editing screen that allows me to create or modify my template. I'm going to make my template extremely simple:

<!-- Start "tofu/column" -->

%# Display this story
% $burner->display_pages('page');

<!-- End "tofu/column" -->

Notice how we put HTML comments around the definition. This makes it easier to debug the template when it is turned into HTML and sent to the user's browser. I can assure you from personal experience that the nested nature of Mason templates, especially with multiple autohandlers, can be maddening.

Once I select and deploy from the Check-In menu, and then click the Check-In button, my template is deployed. Any column with a category of tofu now is formatted with this template rather than the global, more general one for columns.

And, of course, if I want to go back and edit my template, I can do that in the way that we saw earlier—finding it, checking it out and editing it.


Bricolage, like any serious CMS, makes it easy to create a unified look and feel by using templates. Because Bricolage is based on standard open-source tools, such as mod_perl and Apache, it can take advantage of the existing templating systems for mod_perl, including HTML::Mason and the Template Toolkit. This month, we saw how we can create and modify templates associated with various element types and categories, giving us the flexibility we need to generalize a site's look and feel without being constrained.

Reuven M. Lerner, a longtime consultant in Web/database programming, is now a graduate student in Learning Sciences at Northwestern University in Evanston, Illinois. You can reach him at



Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Re: Bricolage Templates

Anonymous's picture

in version 1.8.1 you now need to make a little forward slash in the "fsearch" feild after you click "find template"- in order to indicate you are looking for the first level. A blank feild no longer works.