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 / dspCustomNavWithChildren.cfm
Last active July 19, 2019 07:28
Mura CMS : display a custom navigation based on a content collection/local index and include children up to a specific depth level.
<cfset feed = $.getBean('feed').loadBy(name='Your Feed Name')>
<cfset it = feed.getIterator()>
<cfif it.hasNext()>
<ul class="nav nav-list">
<li class="nav-header">Your Nav Header</li>
<cfloop condition="it.hasNext()">
<cfset item = it.next()>
<li<cfif $.content('contentid') eq item.getContentID()> class="active current"</cfif>>
<a href="#item.getURL()#">#HTMLEditFormat(item.getMenuTitle())#</a>
<!--- This is where you can specify how deep you want to go --->
@stevewithington
stevewithington / getCustomSearch.cfm
Created June 27, 2013 21:13
Mura CMS : Another custom search example. I would not necessarily recommend using this for production purposes, although it should work. Search in general is quite complicated ... hence why we have such companies as Google, Yahoo, Ask, etc. ... so if you truly want a custom search interface, you may actually want to consider using one of the cus…
<!--- First, you could copy the file located under /{SiteID}/includes/display_objects/dsp_search_results.cfm
and then paste it under either /{SiteID}/includes/display_objects/custom/dsp_search_results.cfm
OR under /{SiteID}/includes/themes/{ThemeName}/display_objects/dsp_search_results.cfm
and then change the line of code that sets the variables.rsNewSearch to this --->
<cfset variables.rsNewSearch = variables.$.getContentRenderer().getCustomSearch()>
<!--- Then, place this in your Site's contentRenderer.cfc --->
<cffunction name="getCustomSearch">
<cfscript>
var local = {};
@stevewithington
stevewithington / mura-form-results.cfm
Last active April 27, 2018 19:23
Mura CMS : Iterating over form results. Mura CMS form structures can change, which means fields may be added and/or deleted by Content Managers and thus the form data is stored as XML packets (WDDX, to be exact).
<cfscript>
formName = 'Information Request';
rsData = QueryNew('');
dcm = $.getBean('dataCollectionManager');
</cfscript>
<cfoutput>
<cfif !Len($.event('responseid'))>
<!--- All Form Submission Results --->
<cfscript>
@stevewithington
stevewithington / muraSummarize.cfm
Created July 10, 2013 22:00
Mura CMS : Use these methods to auto-summarize any content.
<cfscript>
// drop these methods into either the Site or Theme's contentRenderer.cfc and use as necessary
public any function summarize(string str='', numeric count='26') {
var local = {};
local.str = arguments.str;
local.count = Val(arguments.count);
if ( Len(Trim(local.str)) ) {
local.str = REReplace($.stripHTML(stripTagContent(local.str)), '[\s|\r\n?|\n]+', ' ', 'ALL');
javaArray = CreateObject('java', 'java.util.Arrays');
wordArray = javaArray.copyOf(local.str.Split(' '), local.count);
@stevewithington
stevewithington / renderEditableAttribute.cfm
Last active December 14, 2023 10:09
Mura CMS : Allow end users to Quick Edit an extended attribute on the front end of the site by using $.renderEditableAttribute()
#$.renderEditableAttribute(
attribute='attributeName'
,type='text|HTMLEditor'
,required=true|false
,validation='blank or a JavaScript regex'
,message='Message to display if it does not pass validation'
,label='Form Field Label'
,value=$.content('attributeName')
,enableMuraTag=true|false
)#
@stevewithington
stevewithington / muraUserEventHandler.cfm
Last active April 30, 2020 15:24
Mura CMS : Examples of how to intercept User creation, update and save events to do some processing of the User Bean and then create custom error messages as well.
<cfscript>
public any function onBeforeUserCreate($, event) {
var user = arguments.event.getValue('userbean');
// do some processing of the user 'bean'
// to create an error message, just add any key to the end of the User's getErrors() struct:
user.getErrors().createFailMessage1 = 'UserCreate fail message goes here. Sorry #user.getFName()#.';
}
public any function onBeforeUserUpdate($, event) {
var user = arguments.event.getValue('userbean');
@stevewithington
stevewithington / $.cfm
Last active November 14, 2019 17:36
Mura Scope ($)
<cfscript>
siteid = IsDefined('session') && StructKeyExists(session, 'siteid') ? session.siteid : 'default';
$ = application.serviceFactory.getBean('$').init(siteid);
</cfscript>
@stevewithington
stevewithington / daysInMonth.js
Last active April 16, 2021 08:55
Simple JavaScript to get the number of days in any given month of any year. Works for February and accounts for leap years! credits: http://www.dzone.com/snippets/determining-number-days-month
function daysInMonth(iMonth, iYear) {
return 32 - new Date(iYear, iMonth, 32).getDate();
}
@stevewithington
stevewithington / dspNestedCategories.cfm
Last active June 11, 2024 17:57
Mura CMS : Display nested categories with links (only if the category has been set to allow content assignments)
<cfscript>
/**
* @parentID Category ParentID
*/
public any function dspNestedCategories(
string siteid='#variables.$.event('siteid')#'
, string parentID=''
, string keywords=''
, boolean activeOnly=false
, boolean InterestsOnly=false
@stevewithington
stevewithington / muraGetFileORImageByFileID.cfm
Created August 16, 2013 20:07
Mura CMS : Mura has two different methods for get a link to a file stored as an extended attribute. The one you choose depends on if you're expecting the file to be an "image" or a "file" ... if it's not a valid image or file, then the methods will return an empty string, which means you can test for the return value and then output it if it exi…
<cfscript>
// simple examples
fileURL = $.getURLForFile('yourFileID');
imageURL = $.getURLForImage('yourFileID');
</cfscript>
<!--- File Example --->
<cfif Len($.getURLForFile($.content('myCustomAttribute')))>
<a href="#$.getURLForFile($.content('myCustomAttribute'))#">Download File</a>
<cfelse>