blogarchive

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

  • Feb 9, 2010
  • The Mura Team
  • Developers

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:
$.content('property');

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

Returns full contentBean:
$.content();

Returns the current content's parent (as contentNavBean base on crumbdata):
$.getParent();

Returns the current content's parent (as full contentBean):
$.content().getParent();

You can also access all built-in contentBean methods:
$.content().getKidsIterator();
$.content().getRelatedContentIterator();
$.content().getCommentsIterator();
$.content().getVersionHistoryIterator();
$.content().save();
(etc...)

Event Scope

The Event scope simply wraps the current requests event object.

Returns value:
$.event('property');

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

Returns full event object:
$.event();

Component Scope

The Component scope is only available from with Mura Components.

Returns value:
$.component('property');

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

Returns full component contentBean:
$.component();

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:
$.currentUser('property');

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

Returns sessionUserFacade:
$.currentUser();

Returns the current user's group memberships:
$.currentUser().getMembershipsIterator();

Site Config

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

Returns value:
$.siteConfig('property');

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

Returns full site settingsBean:
$.siteConfig();

Global Config

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

Returns value:
$.globalConfig('property');

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

$.dspInclude();
$.dspObjects();
$.dspObject();
$.addLink();
$.createHREF();
(etc...)

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.

$.currentUser().setFName("Bob");
$.currentUser().setValue("fname","Bob");
$.currentUser().getMembershipsIterator();
$.currentUser().getAddressesIterator();
$.currentUser().getInterestGroupsIterator();
$.currentUser().save();
$.currentUser().isSuperUser();
$.currentUser().isPrivateUser();
$.currentUser().isInGoup("[groupname]");
$.currentUser().isInGoup("[groupname]",[isPublic]);
$.currentUser().isLoggedIn();
$.currentUser().logout();
(etc...)

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")>
</cffunction>

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

<cffunction name="onPageDefaultBodyRender" output="true>
<cfargument name="$">
<cfoutput>#$.setDynamicContent($.content('body'))#</cfoutput>
</cffunction>

or

<cffunction name="onPageDefaultBodyRender" output="true>
<cfargument name="mura">
<cfoutput>#mura.setDynamicContent(mura.content('body'))#</cfoutput>
</cffunction>

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.

 

 

Developers

Blog Post
By Grant Shepert
Blog Post
By Grant Shepert
Blog Post
By Grant Shepert
Blog Post
By Grant Shepert
Blog Post
By Grant Shepert
Blog Post
By Grant Shepert
Blog Post
By Grant Shepert
Blog Post
By Michael Evangelista
Blog Post
By Grant Shepert
Blog Post
By Grant Shepert
Blog Post
By Michael Evangelista
Blog Post
By Michael Evangelista
Blog Post
By Grant Shepert
Blog Post
By Matt Levine
Blog Post
By The Mura Team
Blog Post
By Pat Santora
Blog Post
By Pat Santora
Blog Post
By Matt Levine
Blog Post
By Matt Levine
Blog Post
By Matt Levine
Blog Post
By Eddie Ballisty
Blog Post
By Sean Schroeder
Blog Post
By Grant Shepert
Blog Post
By Grant Shepert
Blog Post
By Grant Shepert
Blog Post
By Grant Shepert

Marketers

Blog Post
By Andrew Medal
Blog Post
Blog Post
By Ronnie Duke
Blog Post
By Sean Schroeder