Skip to content

Instantly share code, notes, and snippets.

@ronnieduke
ronnieduke / mura-podcast-xml.cfm
Last active November 2, 2015 23:15
How to create a podcast XML feed using Mura CMS
<!--- Add this to your {theme}/remote/podcast.cfm --->
<!--- Set your siteID --->
<!--- This is important because iTunes does not have a session to your Mura site when accessing the XML,
so you have to set the site ID manually --->
<cfset siteid='yourSiteID'>
<cfscript>
$= application.serviceFactory.getBean('$').init(siteid);
// In your Mura Architecture, you will want to create a "Show" for wach of the episodes to live under.
@ronnieduke
ronnieduke / eventHandler.cfc
Created May 1, 2014 22:52
Create iCal files from Mura Events - **Note: some variables in these functions reference extended attributes in the event nodes themselves and will need to be created or altered to make the methods work
<cffunction name="onAfterPageEventSave" output="true">
<cfargument name="$" required="true" hint="mura scope" />
<cfset cfcpath1 = Replace($.siteConfig('themeAssetPath'), "/", ".", "all")>
<cfset cfcpath = Replace(cfcpath1, ".", "")>
<cfscript>
var cBean = $.getBean('content').loadBy(contentID=$.content().getContentID());
var event = StructNew();
var loc = '';
<cfscript>
// Place these methods in your Site, Theme, or Plugin's eventHandler.cfc
public any function onBeforeUserSave($) {
var newUserBean = arguments.$.event('userBean');
var oldUserBean = arguments.$.getBean('user').loadBy(userid=arguments.$.event('userid'));
// if you want to stuff the oldUserBean in the event
// $.event('oldUserBean', oldUserBean);
@ronnieduke
ronnieduke / script.js
Created May 6, 2014 18:10
Treat responsive mobile nav differently
/*================================================================*/
/* DESKTOP MENU
/*================================================================*/
if (document.documentElement.clientWidth > 767) { //if client width is greater than 767px
ddsmoothmenu.init({
mainmenuid: "main_menu",
orientation: 'h',
contentsource: "markup",
showhidedelay: {showdelay: 300, hidedelay: 100} //set delay in milliseconds before sub menus appear and disappear, respectively
@ronnieduke
ronnieduke / mura-submit-form
Created May 6, 2014 18:26
How to send a copy of a Mura form to the form submitter
<!--- Drop this into your site eventhandler.cfc --->
<cffunction name="onAfterFormSubmitSave" output="true">
<cfif $.event('formid') EQ '{ID of the Mura form}'>
<!--- Get the form result --->
<cfset formBean = $.event().getValue('formresult')>
<cfmail
from = "e-mail address"
to = "#formBean.EMAIL#"
subject = "Thank you!"
<!--- 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($){
@ronnieduke
ronnieduke / mura-image-metadata.cfm
Created May 14, 2014 18:32
Get file metadata from Mura associated image
<!--- ==========================================
Use this in any page template or display object
============================================ --->
<!--- The meta for the associated image of a content node --->
<cfset fileBean = $.getBean('fileMetaData').loadBy(contentid=$.content('contentid'))>
<!--- If you want to get the meta from an extended attribute image --->
<cfset fileBean = $.getBean('fileMetaData').loadBy(fileid=$.content('extAttribute'))>
@ronnieduke
ronnieduke / mura-cache-rebuild.cfm
Created May 28, 2014 20:46
Rebuild your image cache in Mura
<!--- Stick this in to your theme/remote/rebuild.cfm --->
<cfset application.serviceFactory.getBean('fileManager').rebuildImageCache(siteid='YOURSITEID')>
@ronnieduke
ronnieduke / muraCleanFiles.cfm
Created May 28, 2014 20:46 — forked from stevewithington/muraCleanFiles.cfm
Clean orphaned files in Mura
<cfset application.serviceFactory.getBean('fileManager').cleanFileCache('[siteid]') />
@ronnieduke
ronnieduke / mura-category-feed.cfm
Created June 13, 2014 22:24
Mura Category Feed
<cfset catBean = $.getBean('category').loadBy(name="Portfolio Item")>
<cfset catFeed = catBean.getKidsQuery()>
<cfset catList = ValueList(catFeed.name)>
<cfloop list="#catList#" index="category">
<li><a href="##" data-filter=".#$.createCSSID(category)#">#category#</a></li>
</cfloop>