Sub Scopes - Mura Docs v6

Sub Scopes

There are several sub-scopes within Mura. Sub-scopes have their own sets of helper methods as well. Let's take a quick look at some of the main ones.

Content Scope

The Content scope wraps the current front end request's contentBean. This gives us both easy access to the contentBean itself as well as a host of 'helper' functions.

The following returns the full contentBean of the current content node:


You can also access the parent's full contentBean of the current front end request using:


Accessing Values (Getters)

All values inside a standard contentBean are accessible through the Content Scope. These are listed in order of best practice, however all will return the same value.


Setting Values (Setters)

Content values can be “set” using the following notation:

$.content('title', 'Your New Title');
$.content().setTitle('Your New Title');
$.content().setValue('title', 'Your New Title');

A Few Helpers

The sub-scopes also include a selection of helper objects, each designed to make working with the content easier.

$.content().getImageURL(height={numberOfPixels or 'auto'}, width={numberOfPixels or 'auto'});
// NOTE: Queries do NOT contain extended attributes!

Important: The second argument of "siteID" is only required when the siteID is not defined or is not the same as the siteID value set in the current Mura Scope's event (e.g., $.event("siteID”)).

Comment Scope


Category Scope


Current User Scope

The Current User scope wraps the Session User Facade object, which in turn wraps the session.mura struct. The main benefit of the Session Facade is that it knows how and when to retrieve data that is not normally stored in the session.mura struct, including extended attributes.


A Few Helpers

$.currentUser().isInGroup('Some Group Name');

You can also save any changes that may be made to user during a session:

$.currentUser('fname', 'John');
$.currentUser('lname', 'Doe');

Site Config Scope

Site Config scope contains site configuration settings and environment variables. This scope is specific to the site in which you're working at the moment.


Key Methods

These methods return the starting URL path to be used with things like JavaScript and CSS file references:


These methods return the starting file path to be used for <cfinclude>:


These methods return the starting component path (or dotted-notation path) for object instantiation:


This returns an instance of the site's contentRenderer for use with static methods:


This returns an instance of the theme's contentRenderer for use with static methods:


Global Config Scope

The Global Config scope wraps the global configuration for your Mura instance, found under:


You can also access any custom key-values that have been created in the /config/settings.ini.cfm by passing in the key used to set the value in the file:


Event Scope

The $.event() scope is a special case. On every request, Mura generates a global event scope (accessible via $.getGlobalEvent()), and there are also contextual events which are fired when specific blocks of code or actions occur. For instance, when content is saved, a contextual event of onBeforeSave() is fired.

$.event() is always available, and is a handy place to access the current SiteID via $.event('siteID'). Additional examples will be covered in the Events section.