Skip to content

Instantly share code, notes, and snippets.

@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">
@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 / 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 / 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 / muraDisableFrontEndTools.cfm
Created April 27, 2018 19:15 — forked from stevewithington/muraDisableFrontEndTools.cfm
Mura CMS : How to disable front end tools and front end editing for public facing sites. This would then allow you to completely delete/remove the 'admin' directory from the production server, and only host it on a dev/staging server that's hosted behind a firewall, assuming each instance is pointing to the same database. NOTE: Do NOT delete you…
<!---
1) Drop this method in your /config/cfapplication.cfm and modify it as you wish.
For example, maybe you only want to allow front end tools if editing the site behind your firewall
--->
<cfscript>
public boolean function getEnableFrontEndTools() {
return getPageContext().getRequest().getServerName() == 'someURLAccessibleOnlyBehindYourFirewall.com';
}
</cfscript>
@mattlevine
mattlevine / muraImportFiles.cfm
Created April 27, 2018 19:15 — forked from stevewithington/muraImportFiles.cfm
Mura CMS : How To Import A Directory Of Files Into Mura As Content Items
<cfscript>
// This will NOT work unless you have 'allowlocalfiles=true' in /config/settings.ini.cfm
// example path to files
try {
filepath = ExpandPath('./files');
} catch(any e) {
filepath = ExpandPath('./');
}
@mattlevine
mattlevine / muraGetAssociatedImageMetaData.cfm
Created April 27, 2018 19:16 — forked from stevewithington/muraGetAssociatedImageMetaData.cfm
Mura CMS: How to get the primary associated image metadata such as AltText, Caption, Credits, etc.
<cfset itKids = $.content().getKidsIterator() />
<cfif itKids.hasNext()>
<ul>
<cfloop condition="itKids.hasNext()">
<li>
<cfscript>
item = itKids.next();
fileid = item.getValue('fileid');
if ( item.hasImage() ) {