Skip to content

Instantly share code, notes, and snippets.

@mattlevine
mattlevine / muraGetUpcomingEventsByFeedname.cfm
Created April 27, 2018 19:14 — forked from stevewithington/muraGetUpcomingEventsByFeedname.cfm
Mura CMS : Example of how to get upcoming calendar events by Feed name
<!---
https://gist.github.com/stevewithington/18a6ef38e7234f1e1fc3
1) Drop this in your Site or Theme contentRenderer.cfc
2) To use, drop the following line of code in your layout template, and modify as you wish:
#$.getUpcomingEventsByFeedname(feedname='Your Feed Name', maxMonths=2, groupDailyEvents=true)#
--->
<cffunction name="getUpcomingEventsByFeedname">
<cfargument name="feedName" type="string" required="true" />
<cfargument name="maxMonths" type="numeric" default="3" />
<cfargument name="groupDailyEvents" default="true" />
@mattlevine
mattlevine / muraCreatePageAndUser.cfm
Created April 27, 2018 19:14 — forked from stevewithington/muraCreatePageAndUser.cfm
Mura CMS : Example of how to create a content item when updating a User
<cfscript>
public any function onAfterUserSave($) {
// reference to new user bean
var user = arguments.$.event('userBean');
// reference to old user bean
//var oldUserBean = arguments.$.getBean('user').loadBy(userid=user.getUserID());
// reference to content item that will be the parent of the 'User' page
var parentbean = $.getBean('content').loadBy(title='Reps');
@mattlevine
mattlevine / muraTopLevelNav.cfm
Created April 27, 2018 19:14 — forked from stevewithington/muraTopLevelNav.cfm
Mura CMS : Example of how to output the top level nav items (excluding home)
<!---
You could always just use dspPrimaryNav(), but here's an easy way to output the top level nav items,
and have complete control over the rendered output.
--->
<cfoutput>
<cfscript>
it = $.getBean('content').loadBy(filename='').getKidsIterator();
</cfscript>
<cfif it.HasNext()>
<nav>
@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">
@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 / 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 / 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 / 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 / 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 / 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()#">