Skip to content

Instantly share code, notes, and snippets.

@mattlevine
mattlevine / onAdminHTMLFootRender.cfm
Created April 27, 2018 19:18 — forked from stevewithington/onAdminHTMLFootRender.cfm
Mura CMS : How to change a label/text in the Admin area.
<!--- Drop this in your Site or Theme Event Handler --->
<cffunction name="onAdminHTMLFootRender">
<cfargument name="event">
<cfargument name="$">
<cfset var scripts = ''>
<cfif StructKeyExists(url, 'muraAction') and url.muraAction eq 'cArch.edit'>
<cfsavecontent variable="scripts">
<script>
jQuery(document).ready(function($){
var newSummary = 'My Summary ' + '<i class="icon-question-sign"></i>';
@mattlevine
mattlevine / muraLogoutHandler.cfm
Created April 27, 2018 19:19 — forked from stevewithington/muraLogoutHandler.cfm
Mura CMS : Redirect user after logout
<cfscript>
public any function standardPostLogoutHandler($, event) {
// you could redirect the user to any url you want here
location(url=arguments.$.createHREF(filename='about'), addtoken=false);
}
</cfscript>
@mattlevine
mattlevine / muraUserStrikesBean.cfm
Created April 27, 2018 19:19 — forked from stevewithington/muraUserStrikesBean.cfm
Mura CMS : User Strikes Bean
<cfscript>
userStrikesBean = $.getBean('userstrikes').init(username=$.currentUser('username'), configbean=$.globalConfig());
WriteDump(var=userStrikesBean.getStrikes());
</cfscript>
@mattlevine
mattlevine / muraAnnounceEvent.cfm
Created April 27, 2018 19:20 — forked from stevewithington/muraAnnounceEvent.cfm
Mura CMS : Announce an Event From a Form
<!--- 1) Create a form with a hidden form field like shown below, and place it in a layout template, or in a display object, etc. --->
<form method="post">
<input type="text" name="myField" value="Some Value">
<input type="hidden" name="myFormIsSubmitted" value="true">
<input type="submit">
</form>
<cfscript>
// 2) In the eventHandler.cfc (Site, Theme, Plugin, or other custom handler) you could listen for the even in one of Mura's eventHandlers such as 'onRenderStart'
public any function onRenderStart(event, m){
@mattlevine
mattlevine / config.xml.cfm
Created April 27, 2018 19:20 — forked from stevewithington/config.xml.cfm
Mura CMS : Example of how to create a Frequently Asked Questions (FAQ) area/section with Mura CMS and Bootstrap3 markup.
<!--
1) Drop this in your theme /{SiteID}/includes/themes/{Theme}/config.xml.cfm
-->
<theme>
<extensions>
<extension type="Folder" subType="FAQ" availableSubTypes="Page/Question" iconClass="icon-question-sign">
</extension>
<extension type="Page" subType="Question" iconClass="icon-question" hasSummary="0" hasBody="0" hasAssocFile="0">
</extension>
@mattlevine
mattlevine / mura-scope.cfm
Created April 27, 2018 19:21 — forked from stevewithington/mura-scope.cfm
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);
@mattlevine
mattlevine / muraRelatedContent.cfm
Created April 27, 2018 19:22 — forked from stevewithington/muraRelatedContent.cfm
Mura CMS : Related Content Iterators and outputting extended attributes
<cfoutput>
<cfscript>
// Content Bean of the Section of the site to narrow feed down to
cBean = $.getBean('content').loadBy(title='Blog');
// Feed Bean
fBean = $.getBean('feed');
fBean.addParam(
relationship='and'
@mattlevine
mattlevine / muraMethodInjection.cfm
Created April 27, 2018 19:22 — forked from stevewithington/muraMethodInjection.cfm
Mura CMS : You can easily override nearly any method in Mura with method injection. This example shows you how to do that.
<cfscript>
// drop this in your eventHandler.cfc
public any function yourMethod() {
// you do something here
}
public any function onApplicationLoad($) {
arguments.$.getBean('someBean').injectMethod('someMethod', yourMethod);
}
@mattlevine
mattlevine / mura-form-results.cfm
Created April 27, 2018 19:23 — forked from stevewithington/mura-form-results.cfm
Mura CMS : Iterating over form results. Mura CMS form structures can change, which means fields may be added and/or deleted by Content Managers and thus the form data is stored as XML packets (WDDX, to be exact).
<cfscript>
formName = 'Information Request';
rsData = QueryNew('');
dcm = $.getBean('dataCollectionManager');
</cfscript>
<cfoutput>
<cfif !Len($.event('responseid'))>
<!--- All Form Submission Results --->
<cfscript>
@mattlevine
mattlevine / muraTracePointExample.cfm
Created April 27, 2018 19:23 — forked from stevewithington/muraTracePointExample.cfm
Mura CMS : Create a Custom Trace Point. To view, login as an admin, then append your URL with ?showTrace=1. A Stack Trace with the duration and running total of milliseconds should appear in a list format. To disable, append your URL with ?showTrace=0
<!--- Place this either at the top of your file, or at the beginning of a block of code you wish to trace --->
<cfset myTracePoint = $.initTracePoint('yourFilenameOrOtherDescriptionToIdentifyThisTracePointGoesHere') />
<!--- file content or block of code goes here --->
<!--- Place this either at the bottom of your file, or at the end of a block of code you wish to trace --->
<cfset $.commitTracePoint(myTracePoint) />