Entries for month: November 2010

Mura CMS Quick Tip: Dynamic Template Rendering

CFML , ColdFusion , Mura CMS 9 Comments »

In Mura CMS, there is the concept of templates that make up your site theme. Your theme can have multiple templates, such as a two-column template and a 3 column template which can be assigned to individual pages in your site. You can read more about templates in Mura here. Recently, while working on a Mura site, I wanted my pages to be able to dynamically use either a 2- or a 3-column template depending on whether something was assigned to the right column display region (which was display region #3 in this site).

So I whipped up this template named default.cfm:

<cfif len( trim($.dspObjects(3)) )>
<cfinclude template="three_column.cfm" />
<cfelse>
<cfinclude template="two_column_SL.cfm" />
</cfif>

So basically it checks to see if anything was assigned to the right column display region. If so, the 3 column template is rendered. If not it defaults to 2 columns. This way, I can just set all pages to the default template and let the content determine whether 2 or 3 columns are used.

Powered by Mango Blog. Design and Icons by N.Design Studio
RSS Feeds