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 / mura-tabs-as-links.cfm
Created March 6, 2015 17:00
Mura CMS: How to create Bootstrap tabs of children content as either links, or with panels.
@stevewithington
stevewithington / mura-save-external-content.cfm
Last active December 14, 2023 10:19
Mura CMS : How to create content dynamically in Mura. There are two primary pieces to the puzzle: 1) Mura needs to know where to add the content. Specifically, it needs to know the ParentID. 2) Remember, there's only one required field when adding content via the UI, and that's the 'Title' field. To do this dynamically, I usually recommend also …
<cfscript>
// This Gist is very much related directly to https://gist.github.com/stevewithington/4742829 on how to import content via RSS.
// However, this is the main code
content = $.getBean('content').loadBy(remoteid = 'PrimaryKeyFromExternalDB');
content.setTitle('theTitle');
content.setMenuTitle(''); // we clear the other title fields so that Mura will auto-generate them based on the actual 'title'
content.setURLTitle('');
content.setHTMLTitle('');
content.setApproved(1);
content.setIsNav(0);
@stevewithington
stevewithington / mura-combine-feeds.cfm
Created March 2, 2015 20:46
Mura CMS : How to combine or commingle multiple feeds/content collections across multiple Mura CMS sites under the same installation.
<cfscript>
// Combine feeds/content collections across multiple Mura sites under same install
feed1 = $.getBean('feed').loadBy(name='Feed Name Goes Here', siteid='SomeSiteID');
feed2 = $.getBean('feed').loadBy(name='Another Feed Name Goes Here', siteid='AnotherSiteID');
// Use Query of Queries to UNION recordsets
qoq = new Query();
qoq.setAttributes(rs1=feed1.getQuery(), rs2=feed2.getQuery());
qoq.setSQL('SELECT * FROM rs1 UNION SELECT * FROM rs2 ORDER BY releasedate');
@stevewithington
stevewithington / running-paces.md
Last active August 29, 2015 14:15
Running Pace Key & Calculator

Running Pace

This is mostly for myself ... I often forget the subtle differences between different paces, and needed an easy place to go for reference.

Running Pace Key

  • Jog recovery – a period of extremely slow running (barely above walking pace) in between the efforts in a speed session.
  • Easy – a gentle jog at below 60% working heart rate (WHR). Running at this intensity will help your body recover between harder workouts, while still building your aerobic fitness and muscle-strength.
  • Slow – conversational pace (60-65% WHR). This is the speed at which you should do your long runs - it might feel awkward at first, but it’s better to hold back initially and last the distance than set off too fast and burn out just a few miles later.
  • Steady – a comfortable, but purposeful, pace, similar to your marathon pace (65-75% WHR). The ‘steady’ run helps teach your body economy, and also familiarises you with the speed you should set off on marathon day. After a few runs at this pace, make a
@stevewithington
stevewithington / muraPasswordExpired.cfm
Last active April 27, 2018 19:13
Mura CMS : How to set an 'Admin' alert in Mura based on the age of someone's password.
<!--- Drop these in the Theme or a Plugin eventHandler.cfc (global events won't work in the Site Handler) --->
<cfset variables.passwordexpired = false />
<!--- Custom method to determine if password is expired --->
<cffunction name="isPasswordExpired" output="false">
<cfargument name="userBean" required="true" />
<cfset var daysUntilExpired = 90 />
<cfset var expires = DateAdd('d', daysUntilExpired, arguments.userBean.getValue('passwordcreated')) />
<cfreturn DateCompare(expires, Now()) eq 1 ? false : true />
@stevewithington
stevewithington / muraContentStatus.cfm
Created January 9, 2015 20:06
Mura CMS: Get status of content (e.g., Draft, Pending Approval, Published, Archived)
<!--- Drop these methods in your Site or Theme contentRenderer.cfc, and get the status with $.getContentStatus() --->
<cffunction name="getContentStatusID" output="false">
<cfset var statusid = '' />
<cfif $.content('active') gt 0 and $.content('approved') gt 0>
<!--- 2: Published --->
<cfset statusid = 2>
<cfelseif len($.content('approvalstatus')) and $.content().requiresApproval()>
<!--- 1: Pending Approval --->
<cfset statusid = 1 />
<cfelseif $.content('approved') lt 1>
@stevewithington
stevewithington / muraCategorizedContent.cfm
Last active October 5, 2018 17:56
Mura CMS: How to loop over categories and output any categorized content.
<cfoutput>
<cfset cats = 'Weather,Local News,Arts & Culture' />
<ul>
<cfloop array="#ListToArray(cats)#" index="c">
<li>
<h3>#HTMLEditFormat(c)#</h3>
<cfscript>
catBean = $.getBean('category').loadBy(name=c, siteid=$.event('siteid'));
feed = $.getBean('feed');
@stevewithington
stevewithington / muraTopLevelNav.cfm
Created December 22, 2014 20:05
Mura CMS : Example of how to output the top level nav items (excluding home)
<!---
You could always just use dspPrimaryNav(), but here's an easy way to output the top level nav items,
and have complete control over the rendered output.
--->
<cfoutput>
<cfscript>
it = $.getBean('content').loadBy(filename='').getKidsIterator();
</cfscript>
<cfif it.HasNext()>
<nav>
@stevewithington
stevewithington / muraSendEmail.cfm
Last active February 20, 2024 14:33
Mura CMS : How to send an email to the person who submitted the form
<!--- Drop this in your Site or Theme eventHandler.cfc --->
<cffunction name="onAfterFormSubmitSave">
<cfargument name="$">
<cfset var msg = '' />
<cfset var formBean = $.event().getValue('formBean') />
<cfset var formResultBean = $.event().getValue('formDataBean') />
<cfset var formResultStruct = $.event().getValue('formDataBean').getValue('formResult') />
<cfif formBean.getTitle() eq 'Your Desired Form Title'>
<cfsavecontent variable="msg">
@stevewithington
stevewithington / recaptcha.cfc
Created December 4, 2014 23:28
Google ReCAPTCHA v2 for ColdFusion / Railo / CFML. See https://github.com/stevewithington/ReCAPTCHA for example usage.
/**
* This is a CFML library that handles calling reCAPTCHA.
* - Documentation and latest version
* https://developers.google.com/recaptcha/
* - Get a reCAPTCHA API Key
* https://www.google.com/recaptcha/admin#list
* - Discussion group
* http://groups.google.com/group/recaptcha
*
* @copyright Copyright (c) 2014, Stephen J. Withington, Jr.