Introducing the Mura Scope

A simple and fast syntax for accessing Mura CMS data and objects

Based on input from our front-end developers, we’ve created a helper object to provide a single point of interaction for all rendering needs (As well as non-rendering situations). For it we have decided to use the “$” prefix like other front-end technologies like jQuery and Prototype/Scriptaculous. It’s short, sweet and familiar. However, if the "$" is too similar for your taste it is also available as simply "mura".

In most rendering situations, Mura 5.2 automatically makes it available. This includes display objects and templates as well as anywhere you would normally use the mura tag.

The new Mura Scope breaks the request context into 6 major scopes (content, event, globalConfig, siteConfig, currentUser and component) and provides access to all rendering methods.  (We won't refactor the display object to use this method until Mura no longer supports CFMX7 because it relies on “onMissingMethod” which isn’t supported by CFMX7. We look forward to this day because display object code will be much more portable.)

Content Scope

The Content scope wraps the current request's contentBean.  All values that you would previously get with request.contentBean.get[Attribute] or event.getContentBean().get[Attribute]  are accessible through it.

Returns value:

Sets and return the value:

Returns full contentBean:

Returns the current content's parent (as contentNavBean base on crumbdata):

Returns the current content's parent (as full contentBean):

You can also access all built-in contentBean methods:

Event Scope

The Event scope simply wraps the current requests event object.

Returns value:

Sets and return the value:

Returns full event object:

Component Scope

The Component scope is only available from with Mura Components.

Returns value:

Sets and return the value:

Returns full component contentBean:

Current User Scope

The Current User scope wraps the new Sesssion User Facade object which in turn wraps the session.mura struct.  The main benefit of the new session facade is that is knows how and when to retrieve data that is not normally store in the session.mura struct include extended attributes.

Returns value:

Sets and return the value:

Returns sessionUserFacade:

Returns the current user's group memberships:

Site Config

The Site Config scope wraps the current site's settings as set in its site settings.

Returns value:

Sets and return the value:

Returns full site settingsBean:

Global Config

The Global Config scope wraps the global configuration which are configured in your Mura intance's /config/settings.ini.cfm.

Returns value:

Sets and return the value:
$. globalConfig('property','propertyValue');

Returns full configBean:
$. siteGlobal();

Helper Methods

Example value content, feed, user, category, userManager.

$.getBean("[bean type]");
$.injectMethod("[method name]", [method instance]);
$.deleteMethod("[method name]");

Template Rendering Methods

All contentRender methods are available


New Session User Facade

This new object is available to all object though the base cfobject by getCurrentUser()
You have access to all built in userBean methods as well as some extra helpers.


Accessing the Mura Scope Object

As stated previous the new Mura scope object is automatically available in most rendering scenarios as both "$" and "mura".  However, in eventHandlers you can access the Mura scope in one of two way.

1. You can simply pull the Mura scope from the current event object that is traditionally passed into mura event handler.

<cffunction name="onPageDefaultBodyRender" output="true>
<cfargument name="event">
<cfset $=event.getValue("muraScope")>

2. Or you can simply adjust your eventHandler methods to expect the Mura scope:

<cffunction name="onPageDefaultBodyRender" output="true>
<cfargument name="$">


<cffunction name="onPageDefaultBodyRender" output="true>
<cfargument name="mura">

The exception to this are the standard events (Events that start with the word standard).  These events can still on be programmed to expect the current event.



This looks very cool. Could this essentially be used to solve the dilemma in the following thread?

February 9, 2010, 3:43 PM
Flag as Spam
Matt Levine

Fyi, I responded to the forum post about how you can achieve what you're trying to do.

February 9, 2010, 4:58 PM
Flag as Spam

Hi there,

Do you know CfWheels?

the "Helper Methods" here is similar to CfWheels' Helper?

May 14, 2011, 11:34 PM
Flag as Spam
Post a Comment

Required Field