Skip to content

Instantly share code, notes, and snippets.

@mattlevine
mattlevine / muraAnnounceEvent.cfm
Created April 27, 2018 19:20 — forked from stevewithington/muraAnnounceEvent.cfm
Mura CMS : Announce an Event From a Form
<!--- 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(event, m){
@mattlevine
mattlevine / muraUserStrikesBean.cfm
Created April 27, 2018 19:19 — forked from stevewithington/muraUserStrikesBean.cfm
Mura CMS : User Strikes Bean
<cfscript>
userStrikesBean = $.getBean('userstrikes').init(username=$.currentUser('username'), configbean=$.globalConfig());
WriteDump(var=userStrikesBean.getStrikes());
</cfscript>
@mattlevine
mattlevine / muraLogoutHandler.cfm
Created April 27, 2018 19:19 — forked from stevewithington/muraLogoutHandler.cfm
Mura CMS : Redirect user after logout
<cfscript>
public any function standardPostLogoutHandler($, event) {
// you could redirect the user to any url you want here
location(url=arguments.$.createHREF(filename='about'), addtoken=false);
}
</cfscript>
@mattlevine
mattlevine / onAdminHTMLFootRender.cfm
Created April 27, 2018 19:18 — forked from stevewithington/onAdminHTMLFootRender.cfm
Mura CMS : How to change a label/text in the Admin area.
<!--- Drop this in your Site or Theme Event Handler --->
<cffunction name="onAdminHTMLFootRender">
<cfargument name="event">
<cfargument name="$">
<cfset var scripts = ''>
<cfif StructKeyExists(url, 'muraAction') and url.muraAction eq 'cArch.edit'>
<cfsavecontent variable="scripts">
<script>
jQuery(document).ready(function($){
var newSummary = 'My Summary ' + '<i class="icon-question-sign"></i>';
@mattlevine
mattlevine / mura-content-tab-event-example.cfm
Created April 27, 2018 19:17 — forked from stevewithington/mura-content-tab-event-example.cfm
Mura CMS : Example of how to use one of Mura's Content Tab Events to display a Custom UI field.
<!---
Place this method in your Site, Theme, or Plugin's eventHandler.cfc
See http://docs.getmura.com/v6/back-end/events/content-tab-events/ for more Content Tab Events
--->
<cffunction name="onContentTabBasicTopRender">
<cfset var local = {} />
<!--- This assumes you've created some extended attributes to account for each custom form field --->
<cfsavecontent variable="local.str">
<div class="fieldset">
<div class="form-group control-group">
@mattlevine
mattlevine / muraCalendarUtilityExamples.cfm
Created April 27, 2018 19:17 — forked from stevewithington/muraCalendarUtilityExamples.cfm
Mura CMS : New CalendarUtility Bean Usage Examples
<cfscript>
// 1) Drop these methods into your Theme or Site contentRenderer.cfc
// 2) Create a component called 'Upcoming Events' and using the Mura tag, call [m]$.getUpcomingEvents(calendarid='Events')[/m]
// 3) You can also control how many months of data you wish to retrieve and the maxItems to return
// For example: [m]$.getUpcomingEvents(calendarid='Events', months=3, maxItems=3)[/m]
// NOTE: The code examples assume you have a 'Calendar' with a Title of 'Events'
public any function getUpcomingEvents(
string calendarid=''
, string feedid = ''
, numeric months=3
@mattlevine
mattlevine / muraGroupCalendarEvents.cfm
Created April 27, 2018 19:16 — forked from stevewithington/muraGroupCalendarEvents.cfm
Mura CMS : Example of how to group Mura CMS calendar events together. Another example can be found at https://gist.github.com/stevewithington/18a6ef38e7234f1e1fc3
<!--- See https://gist.github.com/stevewithington/18a6ef38e7234f1e1fc3 for a better example! --->
<cfscript>
it = $.getBean('feed').loadBy(name='Your Feed Name').getIterator(
from=Now()
, to=DateAdd('m', 2, Now())
);
rs = $.getCalendarUtility().filterCalendarItems(it.getQuery(),0);
</cfscript>
<ul>
<cfoutput query="rs" group="contentid">
@mattlevine
mattlevine / muraSaveImage.cfm
Created April 27, 2018 19:16 — forked from stevewithington/muraSaveImage.cfm
Mura CMS : How To Dynamically Add Images or Photos To Content Items
<cfscript>
// This will NOT work unless you have 'allowlocalfiles=true' in /config/settings.ini.cfm
// read image info on local file for default value
try {
ir = ImageRead('steve-withington.jpg');
img = ir.source;
} catch(any e) {
img = '';
}
@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() ) {
@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('./');
}