Installation Wide contentRenderer for MuraCMS

I have a fairly large Mura installation, with a good number of sites on it. I have some customizations that I’d like to be pushed out across all of the sites in my installation. For example, I’ve changed the way the dspPrimaryNav function works, so that I can prevent child pages from being displayed. Unfortunately, as flexible and customizable as Mura is, there is no good to make global changes to the contentRenderer.cfc without losing those changes everytime you perform an update to your core files.

To make this happen, we’re going to use the flexibility of extending components to create a custom contentRenderer.cfc that all sites in our installation will use. So first, we’ll create a directory at the root of our Mura installation called custom. In here we’re going to place all global custom functions we want to override. Here’s mine:

<cfcomponent extends="mura.content.contentRenderer">

    <cfset this.jslib="jquery"/>
    <cfset this.jsLibLoaded=true>
    <cfset this.headline="h1"/>
    <cfset this.subHead1="h2"/>
    <cfset this.subHead2="h3"/>
    <cfset this.subHead3="h4"/>
    <cfset this.subHead4="h5"/>

    <!--- Adjusted to nav to add the ability to prevent all children from being displayed --->
    <cffunction name="dspNestedNavPrimary" output="false" returntype="string">
        ... a bunch of custom code here ...


    <cffunction name="dspPrimaryNav" returntype="string" access="public">
        ... a bunch of custom code here ...



Don’t worry about the two functions. The only really juicy bit there is the extends="mura.content.contentRenderer", which is the way Mura suggests you implement your own custom contentRenderer.cfc. So now that that’s complete, let’s go into our site folder at oursite/includes/ and open the contentRenderer.cfc file there. Change the code to this:

<cfcomponent extends="custom.contentRenderer">


Now your site’s contentRenderer.cfc will pick up the custom methods in your custom.contentRenderer which will in turn pick up all of the default methods in mura.content.contentRenderer. Now you just need to make sure that every site’s contentRenderer extends custom.contentRenderer and you’re good go to.

One thing to watch for here is that if you use the Site Bundle feature, when you deploy the bundle to another server, if the custom.contentRenderer.cfc does not exist, you’ll get errors. So just be mindful of that, and you’re good to go.

Posted by Daniel Short on Mar 13, 2011 at 4:44 PM | Categories: ColdFusion - Mura CMS -


Seb Duggan

Seb Duggan wrote on 03/14/11 3:14 AM

Nice tip Dan - obvious, really, but I'd still have carried on customising each and every contentRenderer.cfc with all the same changes...
Daniel Short

Daniel Short wrote on 03/14/11 9:54 AM

Glad you liked it :). I was making some adjustments to the dspPrimaryNav in a dozen different contentRenderer and the lazy light came on :).

Bash wrote on 03/14/11 2:17 PM

You knew I was going to be in Mura training today, didn't you. ;^)
Sean Schroeder

Sean Schroeder wrote on 03/14/11 11:29 PM

Hi Dan, good post. I have a question though...I'm assuming "shared resources > display objects" and customizing the site-specific contentRenderer.cfc is still too restrictive? Is there a reason why you couldn't then extend the site-specific one in an individual theme?
Michael Evangelista

Michael Evangelista wrote on 03/15/11 12:28 AM

@dan: do we get a Mura tip-of-the-day all week? Timing was perfect, combined with what we saw today, i totally get what you did here. but what's this? @bash: say hey tomorrow. I'm in the back ;-)
Michael Evangelista

Michael Evangelista wrote on 03/15/11 12:17 PM

Day 2 - just explored all the many things mura stores in "this" scope. And here, you're just overriding with another 'set'. Sweet.
Daniel Short

Daniel Short wrote on 03/15/11 12:37 PM

@Sean. The issue with using the site-specific contentRenderer, is that I have some changes (that I hope you guys will roll into the default Mura.contentRenderer) that I want to apply to every site in my Mura installation. For example, I've added an additional argument to the dspPrimaryNav and dspNestedPrimaryNav that will prevent child nodes from display... ever... which makes it really easy for me to create a simple list of footer navigation links. With the current implementation of those two functions, I have to manually put the links into my footer, and if the main navigation changes for some reason, my footer becomes out of date. So now all sites under my Mura installation get the benefit of my changes, and I don't have to worry about the changes getting wiped out during the next update to the default contentRenderer.