Skip to content

Instantly share code, notes, and snippets.

View stevewithington's full-sized avatar
⛑️
solving problems

Steve Withington stevewithington

⛑️
solving problems
View GitHub Profile
@stevewithington
stevewithington / onDisplayRender.cfc
Last active December 21, 2015 07:29
Mura CMS : In 6.1, you will be able to define your own display events via 'display=someAction'
<cfscript>
// you can even trigger the display event
$.event('display', 'help');
// place this in your Site or Theme eventHandler.cfc
public any function onDisplayRender($) {
var str = '';
switch(arguments.$.event('display')) {
case 'someAction' :
try {
@stevewithington
stevewithington / muraImage.cfm
Last active April 28, 2020 15:26
Mura CMS : Meta Image / Primary Associated Image Output
<!---
This is one way to generate a custom meta image based on the content item's primary associated image.
You could use this method in several other ways as well, such as inside a content iterator, etc.
If the fileid passed into this method is not a valid image, then it will return an empty string
--->
<cfif Len($.getURLForImage($.content('fileid')))>
<cfscript>
img = $.getURLForImage(
fileid = $.content('fileid') // could be _any_ fileid in Mura
,size = 'custom' // small, medium, large, custom, or any other pre-defined image size
@stevewithington
stevewithington / muraCMSGroupMembers.cfm
Last active June 6, 2017 21:27
Mura CMS : How to obtain a recordset and iterator of members of a specific group.
<cfscript>
groupBean = $.getBean('user').loadBy(
groupname='Admin'
, siteid=$.event('siteid')
);
// recordset
rsGroupMembers = groupBean.getMembersQuery();
// iterator
@stevewithington
stevewithington / muraCMSMailingListMembers.cfm
Created August 26, 2013 21:41
Mura CMS : How to obtain a recordset of members of a specific mailing list.
<cfscript>
// first, obtain the mailing list ID
mlid = $.getBean('mailingListBean').loadBy(
name = 'Mailing List Name Goes Here'
, siteid = $.event('siteid')
).getMLID();
mlm = $.getBean('mailingListManager');
@stevewithington
stevewithington / muraAppendReleaseDate.cfm
Last active August 4, 2016 05:02
Mura CMS : How to dynamically append the content release date to the body area.
<cfscript>
// drop this in your eventHandler.cfc
public any function onRenderStart($) {
var local = {};
if ( Right($.content('parentid'), 3) != 'END' && ListFindNoCase('News,Blog', $.content().getParent().getTitle()) && Len($.content('releaseDate')) ) {
local.newContent = '<h3>By #HTMLEditFormat($.content("credits"))#</h3><p class="releaseDate">#LSDateFormat($.content('releaseDate'))#</p>' & $.content('body');
$.content('body', local.newContent);
}
}
</cfscript>
@stevewithington
stevewithington / muraCFStatic.cfm
Last active December 22, 2015 00:49
Mura CMS : You don't have to rely on Mura's $.static() method ... you can create your own reference to CFStatic.
<cfscript>
// drop this in your eventHandler.cfc's onSiteRequestStart() method
var themeAssetPath = arguments.$.siteConfig('themeAssetPath');
arguments.$.cfStatic = new requirements.org.cfstatic.CfStatic(
staticDirectory = ExpandPath('#themeAssetPath#')
, outputDirectory = 'compiled'
, staticURL = '#themeAssetPath#/'
, minifyMode = 'package'
, checkForUpdates = !arguments.$.siteConfig('cache')
);
@stevewithington
stevewithington / muraSessionTimeout.cfm
Created September 5, 2013 18:14
Mura CMS : How to alter sessiontimeout based on domain
<cfscript>
// Mura CMS : How to alter sessiontimeout based on domain
// drop this in /config/cfapplication.cfm
host = getPageContext().getRequest().getHeader('Host');
switch(host) {
case 'www.intranet.com' :
this.sessiontimeout = CreateTimeSpan(7,0,0,0);
break;
case 'www.not-intranet.com' :
@stevewithington
stevewithington / mura-onBeforeContentSave.cfm
Last active February 1, 2019 10:04
Mura CMS : Example of how to intercept a contentBean before it is saved, and set error(s) if needed.
<cfscript>
// Drop this function in your Site, Theme, or Plugin's eventHandler.cfc
public any function onBeforeContentSave($) {
// reference to the newBean
var newBean = arguments.$.event('newBean');
// reference to the original contentBean
var oldBean = arguments.$.event('contentBean');
// example on how to create some errors
var error = '';
@stevewithington
stevewithington / muraMethodInjection.cfm
Last active December 14, 2023 10:32
Mura CMS : You can easily override nearly any method in Mura with method injection. This example shows you how to do that.
<cfscript>
// drop this in your eventHandler.cfc
public any function yourMethod() {
// you do something here
}
public any function onApplicationLoad($) {
arguments.$.getBean('someBean').injectMethod('someMethod', yourMethod);
}
@stevewithington
stevewithington / mura-onAfterFormSubmitSave.cfm
Last active January 22, 2018 22:38
Mura CMS: Example of how to intercept form data after it's been saved.
<cffunction name="onAfterFormSubmitSave">
<cfargument name="$">
<cfoutput>
<p>The title of this page is: #$.content('title')#<br>
The form submitted is: #$.event('formbean').getValue('title')#</p>
<cfdump var="#$.event('formbean').getAllValues()#">
<cfabort />
</cfoutput>
</cffunction>