Skip to content

Instantly share code, notes, and snippets.

@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 / 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'))>
<!--- 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-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!"
@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
<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 / 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 = '';
@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 / mura-multi-level-main-nav.cfm
Created April 30, 2014 21:39
This trick comes in handy if you want to use Mura's Multi-Level Nav to power the navigation for your entire site (as opposed to dspPrimaryNav() ). Helpful if you want to use Mura to create a Documentation site for example with many nested levels in the sidebar.
<!--- Add this to any page template or include --->
<!--- By setting the contentID=00000000000000000000000000000000001, Mura will allow top level pages to render in the nav. --->
<nav id="navMultilevel" class="mura-nav-standard sidebar-nav well">
#$.dspNestedNav(
contentID='00000000000000000000000000000000001',
viewDepth=4,
currDepth=1,
sortBy='orderno',
sortDirection='asc',
subNavExpression="listFindNoCase('Page,Calendar',rsSection.type) and listFind($.content('path'),rsSection.contentID) and arguments.currDepth lt arguments.viewDepth"
@ronnieduke
ronnieduke / mura-single-page.cfm
Created April 12, 2014 20:25
Display a single page site using the Mura Iterator. This is in context of a parallax theme that needed multiple dom elements of the same content.
<cfoutput>
<cfinclude template="inc/html_head.cfm" />
<!--- By getting a feed with a blank value, Mura will return all pages underneith the homepage --->
<cfset feed=$.getBean("content").loadBy(filename='',siteID=$.event("siteid"))>
<cfset iterator=feed.getKidsIterator()>
<cfif iterator.hasNext()>
<body id="home">
<!--- add the "home" page statically --->
<div class="scroll-holder" data-stub="###$.createCSSid($.content('menuTitle'))#-stub" data-image="#$.content().getImageURL('source')#" data-speed="#$.content('pDataSpeed')#"></div>