Skip to content

Instantly share code, notes, and snippets.

@mattlevine
Forked from stevewithington/mura-scope.cfm
Created April 27, 2018 19:21
Show Gist options
  • Save mattlevine/811bd1c46a5566662cac6f4de95d9e79 to your computer and use it in GitHub Desktop.
Save mattlevine/811bd1c46a5566662cac6f4de95d9e79 to your computer and use it in GitHub Desktop.
Mura CMS : There will be times when you need to access the Mura Scope ($), but you're not in the context of a front end request. Here's an example of how you could do that, assuming your within the Application scope of Mura.
<cfscript>
// The Mura Scope : in order to access site-specific helpers (e.g., $.siteConfig()), we'll initialize it with a siteid.
$ = StructKeyExists(session, 'siteid')
? application.settingsManager.getBean('$').init(session.siteid)
: application.settingsManager.getBean('$').init('default');
// If you're not in the context of a Front-End Request, then there is NO ContentBean!
// So, we need to set it if we want to access it
// contentBean = $.getBean('content').loadBy(filename='home');
// $.setContentBean(contentBean);
</cfscript>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment