Skip to content

Instantly share code, notes, and snippets.

@ronnieduke
ronnieduke / mura-Extended-Attribute-File.cfm
Last active November 6, 2015 20:18 — forked from modmedia/mura-Extended-Attribute-File.cfm
Get URL for a Mura extended attribute file
<!--- In a Mura page template --->
#$.getURLForFile(fileid=$.content('extAttribute'))#
<!--- In a Mura component --->
#$.getURLForFile(fileid=$.component('extAttribute'))#
<!--- In a Mura iterator --->
#$.getURLForFile(fileid=item.getExtAttribute())#
@ronnieduke
ronnieduke / muraCustomUI.cfm
Created October 31, 2015 17:52 — 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!
@ronnieduke
ronnieduke / code-1.cfm
Last active November 8, 2015 16:27 — forked from bennadel/code-1.cfm
UPDATE: Parsing CSV Data Files In ColdFusion With csvToArray()
<cffunction
name="csvToArray"
access="public"
returntype="array"
output="false"
hint="I take a CSV file or CSV data value and convert it to an array of arrays based on the given field delimiter. Line delimiter is assumed to be new line / carriage return related.">
<!--- Define arguments. --->
<cfargument
name="file"
<!--- Assuming you've created an extended attribute 'File' type called 'extAttributeImage' --->
<!--- In a Mura Page Template --->
#$.createHREFForImage(fileid=$.content('extAttributeImage'),size='myCustomSize')#
<!--- In a Mura Component --->
#$.createHREFForImage(fileid=$.component('extAttributeImage'),size='myCustomSize')#
<!--- From a site extended attribute --->
#$.createHREFForImage(fileid=$.siteConfig('extAttributeImage'),size='myCustomSize')#
loadEmbedShepherd(function(){
if(window.wistiaEmbeds===undefined){
return;
}
window.wistiaEmbeds.onFind(function(video) {
video.addPlugin("marketo", {
src: "js/MarketoWistiaPlugin.js",
outsideIframe: true
});
});
@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]') />
<!--- 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($){
<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);
<!--- 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')>
<!--- Get a new content bean --->
<cfset cBean = application.contentManager.getBean()>
<!--- Set the new node attributes --->
<cfset cBean.setSiteID($.event('siteid'))>
component extends='mura.cfobject' {
// drop this in your site or theme eventHandler.cfc
public any function onRenderStart($) {
// allow for a 'View As PDF' link (e.g., <a href="./?viewAsPDF=1">View As PDF</a>)
if ( IsBoolean(arguments.$.event('viewAsPDF')) && arguments.$.event('viewAsPDF') ) {
arguments.$.content('template', 'pdf.cfm');
}