Skip to content

Instantly share code, notes, and snippets.

@mattlevine
mattlevine / onContentEditMessageRender.cfm
Created April 27, 2018 19:09 — forked from stevewithington/onContentEditMessageRender.cfm
Mura CMS: Admin Alert & Help Block Messages
<cfscript>
// add to an event handler
public any function onContentEditMessageRender(event, m) {
// reference to the event, if needed
var e = arguments.event;
// could also get a reference to event via Mura Scope
var mse = arguments.m.event();
// this example merely shows how to render a simple message
@mattlevine
mattlevine / component_index.cfm
Created April 27, 2018 19:09 — forked from stevewithington/component_index.cfm
Mura CMS: How to enable editable components in Mura 7 similar to how they worked in Mura 6.
<!---
NOTE:
In Mura 6, using '$.dspObject(object='component', objectid='Some Component')' in a layout template
would generate a pencil icon for content manager to edit the component from the front-end view of the site.
In Mura 7, we have migrated to using a layout manager for front-end edits. However, this old functionality no longer works.
So, here's a workaround to accomplish something very similar to the functionality in Mura 6.
1. Under your theme, create a directory labeled 'content_types' if it doesn't already exist
2. Under the 'content_types' directory, create another directory labeled 'component'
@mattlevine
mattlevine / mura-js-form.js
Created April 27, 2018 19:09 — forked from stevewithington/mura-js-form.js
Mura CMS: How to manipulate the DOM of a form in Mura CMS v7+
<script>
Mura.DisplayObject.Form.reopen({
onAfterRender: function() {
//this.context.targetEl is a pointer to the dom element that contains the rendered Mura form.
var container = Mura(this.context.targetEl);
console.log(this.context.targetEl);
}
@mattlevine
mattlevine / primary-nav-with-images.cfm
Created April 27, 2018 19:10 — forked from stevewithington/primary-nav-with-images.cfm
Mura CMS: Custom primary navigation with primary associated images as links.
<!--- Mura 6.2 Syntax (will work in 7.0 as well) --->
<cfset it = $.getBean('feed').addParam(relationship='AND', field='parentid', condition='EQ', criteria='00000000000000000000000000000000001').getIterator() />
<!--- Mura 7.0 Syntax --->
<!--- <cfset it = $.getBean('feed').where().prop('parentid').isEQ('00000000000000000000000000000000001').getIterator() /> --->
<cfif it.hasNext()>
<ul>
<cfloop condition="it.hasNext()">
<cfset item = it.next() />
<li>
<a href="#item.getURL()#">
@mattlevine
mattlevine / mobile-body.cfm
Created April 27, 2018 19:10 — forked from stevewithington/mobile-body.cfm
Mura CMS: Display mobile body vs. regular body content
<!---
Use to display mobile specific content (assumes you have an attribute called 'mobilebody')
--->
<cfset mybody = request.muramobilerequest == 1
&& YesNoFormat(m.content('hasmobilebody'))
&& Len(m.content('mobilebody'))
? m.content('mobilebody')
: m.content('body') />
@mattlevine
mattlevine / muraRebuildImageCache.cfm
Created April 27, 2018 19:10 — forked from stevewithington/muraRebuildImageCache.cfm
Mura CMS: Rebuild image cache or re-save images on redefined image sizes
<!--- Force Image Resave for All Images --->
<cfset application.serviceFactory.getBean('fileManager').rebuildImageCache(siteid='YOURSITEID')>
<!--- or to just reset a specific image size you can use --->
<cfset application.serviceFactory.getBean('fileManager').rebuildImageCache(siteid='YOURSITEID' ,size='YOURSIZE')>
@mattlevine
mattlevine / muraCustomUI.cfm
Created April 27, 2018 19:11 — forked from stevewithington/muraCustomUI.cfm
Mura CMS: Example of how to use the 'Custom UI' container/tab assignment option when creating a class extension.
<!---
A brief example on how to use the 'CustomUI' option when creating a class extension in Mura CMS.
This example assumes you have an extended attribute called 'Page/Book'.
It also assumes you have an attribute set using the 'CustomUI' container/tab assignment.
Any extended attributes you assign to the attribute set, you are responsible for collecting
that data using your own form fields. Make sure the 'name' and 'id' attributes match the
names you've used when you created the extended attributes! For example, if you have an
extended attribute with a name of 'bookPublisher', make sure you have a form field with an
'id' and 'name' attribute of 'bookPublisher'. Check your casing too!
@mattlevine
mattlevine / mura-exportVersionHistoryAsCSV.cfm
Created April 27, 2018 19:12 — forked from stevewithington/mura-exportVersionHistoryAsCSV.cfm
Mura CMS : Example of how to get the version history of all content items, and how to export version history as a CSV file.
<cfscript>
// Example of how to get a CSV report of all content items
// Drop this under a temp directory under the Mura webroot
// You could explicitly set this to any siteid you want, if desired
if ( !IsDefined('$') ) {
siteid = StructKeyExists(session, 'siteid') ? session.siteid : 'default';
$ = application.serviceFactory.getBean('$').init(siteid);
}
@mattlevine
mattlevine / muraPasswordExpired.cfm
Created April 27, 2018 19:13 — forked from stevewithington/muraPasswordExpired.cfm
Mura CMS : How to set an 'Admin' alert in Mura based on the age of someone's password.
<!--- Drop these in the Theme or a Plugin eventHandler.cfc (global events won't work in the Site Handler) --->
<cfset variables.passwordexpired = false />
<!--- Custom method to determine if password is expired --->
<cffunction name="isPasswordExpired" output="false">
<cfargument name="userBean" required="true" />
<cfset var daysUntilExpired = 90 />
<cfset var expires = DateAdd('d', daysUntilExpired, arguments.userBean.getValue('passwordcreated')) />
<cfreturn DateCompare(expires, Now()) eq 1 ? false : true />
@mattlevine
mattlevine / muraSendEmail.cfm
Created April 27, 2018 19:13 — forked from stevewithington/muraSendEmail.cfm
Mura CMS : How to send an email to the person who submitted the form
<!--- Drop this in your Site or Theme eventHandler.cfc --->
<cffunction name="onAfterFormSubmitSave">
<cfargument name="$">
<cfset var msg = '' />
<cfset var formBean = $.event().getValue('formBean') />
<cfset var formResultBean = $.event().getValue('formDataBean') />
<cfset var formResultStruct = $.event().getValue('formDataBean').getValue('formResult') />
<cfif formBean.getTitle() eq 'Your Desired Form Title'>
<cfsavecontent variable="msg">