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 / muraCustomPrimaryNav.cfm
Created August 8, 2014 00:08
Mura CMS : A Custom Primary Nav Example
<cfscript>
feed = $.getBean('feed')
.setMaxItems(0)
.setNextN(0)
.setSortBy('orderno')
.setSortDirection('asc')
.addParam(
relationship='AND'
,field='tcontent.parentid'
,dataType='varchar'
@stevewithington
stevewithington / muraSessionVars.cfm
Created August 7, 2014 23:13
Mura CMS : Session Variable Example
<cfscript>
public any function onSiteRequestStart($) {
param name='session.customsession' default=getDefaultCustomSessionSettings();
// you could use whatever trigger you want to set your session var(s), but i'm just using something simple for this example
if ( IsDefined('url.somekey') ) {
lock scope='session' type='exclusive' timeout=10 {
session.customsession = {
somekey = url.somekey
, dateinitalized = Now()
@stevewithington
stevewithington / githubLinks.md
Created July 25, 2014 15:23
Linking to line numbers on Github
@stevewithington
stevewithington / muraGetMyEvents.cfm
Created July 23, 2014 20:27
Mura CMS : getMyEvents()
<cfscript>
public any function getMyEvents(calendarid=variables.$.content('contentid'), months=6) {
var local = {};
local.util = variables.$.getCalendarUtility();
local.rsItems = local.util.getCalendarItems(
calendarid=arguments.calendarid
, start=Now()
, end=DateAdd('m', arguments.months, Now())
);
return rsItems;
@stevewithington
stevewithington / dspColumnizedChildren.cfm
Last active February 20, 2020 09:38
Mura CMS : How to iterate over a content item's children and output an image and link, in a columnized format.
<!---
1) Drop this in your Site or Theme contentRenderer.cfc
2) Call this on a template: #$.dspColumnizedChildren(columns=3, imageSize='medium')#
3) Or within the editor via Mura tags [m]$.dspColumnizedChildren(columns=3, imageSize='medium')[/m]
--->
<cffunction access="public" output="false" returntype="any" name="dspColumnizedChildren">
<cfargument name="columns" default="3" type="numeric" />
<cfargument name="imageSize" default="medium" type="string" />
<cfscript>
var str = '';
@stevewithington
stevewithington / onAdminHTMLFootRender.cfm
Last active April 27, 2018 19:18
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>';
@stevewithington
stevewithington / mura404.cfm
Created July 3, 2014 15:38
Mura CMS: By default, Mura will not throw a 404 on missing ".cfm" files. This is intended behaviour so that you can integrate existing applications with Mura. If you wish to override this behaviour, use the method in this Gist.
<cfscript>
// drop this into your SITE or THEME eventHandler.cfc to trigger a 404 on missing .cfm files
public any function onSiteRequestStart($) {
request.uri = GetPageContext().GetRequest().GetRequestURI();
request.template = Right(request.uri, 1) != '/' ? ListLast(request.uri, '/') : '';
if ( Len(request.template) && !FileExists(ExpandPath(request.template)) ) {
request.currentfilenameadjusted = request.template;
}
}
</cfscript>
@stevewithington
stevewithington / muraGetUpcomingEvents.cfm
Last active July 22, 2016 23:14
Mura CMS : Example of how to retrieve the next "N" upcoming calendar events.
<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()[/m]
// 3) You can also control how many months of data you wish to retrieve and the maxItems to return
// For example: [m]$.getUpcomingEvents(months=3, maxItems=3)[/m]
public any function getUpcomingEvents(
string calendarid='#variables.$.content('contentid')#'
, numeric months=1
, numeric maxitems=6
, string categoryid='#variables.$.event('categoryid')#'
@stevewithington
stevewithington / isoDateTimeFormat.cfm
Created July 1, 2014 17:40
ColdFusion / CFML : Format date/time to ISO 8601
<cfscript>
public any function isoDateTimeFormat(date timestamp='#Now()#') {
var dt = DateConvert('local2utc', arguments.timestamp);
return DateFormat(dt, 'yyyy-mm-dd') & 'T' & TimeFormat(dt, 'HH:mm:ss.000') & 'Z';
}
</cfscript>
@stevewithington
stevewithington / getWeekOfMonth.cfm
Last active August 29, 2015 14:03
ColdFusion / CFML : Get Week of Month (1-5)
<cfscript>
public any function getWeekOfMonth(date d='#Now()#', numeric minDaysInFirstWeek=1) {
var cal = CreateObject('java', 'java.util.GregorianCalendar').init(
JavaCast('int', Year(arguments.d))
, JavaCast('int', Month(arguments.d)-1)
, JavaCast('int', Day(arguments.d))
, JavaCast('int', Hour(arguments.d))
, JavaCast('int', Minute(arguments.d))
, JavaCast('int', Second(arguments.d))
);