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 / muraFindAndReplace.cfm
Last active April 25, 2019 04:08
Mura CMS : Find old links in Mura CMS and replace/update them with new ones, quickly and easily with this little script.
<cfscript>
// place this in your Site or Theme eventHandler.cfc, then reload your application!
public any function onApplicationLoad($) {
arguments.$.getBean('contentUtility').findAndReplace(
find='http://olddomain.com'
, replace='http://newdomain.com'
, siteid=arguments.$.event('siteid')
);
}
</cfscript>
@stevewithington
stevewithington / onAdminHTMLFootRender.cfm
Created December 11, 2013 22:23
Mura CMS : How to add a custom link to Mura's Admin navigation.
<cfscript>
// Add this to an eventHandler.cfc
public any function onAdminHTMLFootRender($) {
var str = '';
// this will add a link to the bottom of the 'Modules' button in the back end admin area
savecontent variable='str' {
WriteOutput('<script>
jQuery(document).ready(function($){
$("##navSecondary").append(''<li><a href="/some-url/"><i class="icon-cog fa-cog"></i> Some URL</a></li>'');
});
@stevewithington
stevewithington / mura-onBeforeFormSubmitSave-onFormSubmitErrorRender.cfm
Last active September 12, 2019 20:44
Mura CMS : This is an example of how to perform server side validation of Mura CMS form submissions and display an error message to the end user. This leverages the onBeforeFormSubmitSave and the onFormSubmitErrorRender (as of 6.1) methods.
<cfscript>
// Drop this in your Site or Theme eventHandler.cfc
public any function onBeforeFormSubmitSave($) {
// reference to the formBean
var formBean = arguments.$.event('formDataBean');
// example on how to create some errors
var error = '';
var errors = {};
@stevewithington
stevewithington / mura-summaryPages.cfm
Created December 12, 2013 23:09
Mura CMS : If a File or Link content type is a child of the Folder, then we want users to go directly to the file or link ... otherwise, File and Link types linked elsewhere in Mura can be taken to a "Summary" view.
<cfscript>
// drop this in your Site or Theme eventHandler.cfc
public any function onRenderStart($) {
if ( $.event('showMeta') != 2 && $.content().getParent().getValue('type') != 'Folder' ) {
$.event('showMeta', 1);
}
}
</cfscript>
@stevewithington
stevewithington / muraFormCustomObjectOptions.cfc
Last active November 20, 2020 15:13
Mura: Example of how to populate a Mura Form Builder select menu, radio group, or checkbox options with data from a SQL recordset via Custom Object option
component {
/**
* MURA FORM: `CUSTOM OBJECT` Options Example
*
* Notes:
* + On the form, select `Custom Object` and enter the dotted notation path to where this file resides under `/sites/{SiteID}`
* - For example, if the file is located under `/sites/default/remote/muraFormCustomObjectOptions.cfc`
* - Enter: `remote.muraFormCustomOptions`
* - Keep in mind, Mura will be looking for the `getData()` method! See below.
* + How to use a REMOTE SOURCE for options: <https://gist.github.com/stevewithington/115b5ac681fe35d42505b1cdedad1593>
@stevewithington
stevewithington / dspSWF.cfm
Last active December 31, 2015 23:19
Mura CMS : Display a .swf file quickly and easily using this dspSWF() method. Drop it into your Site or Theme contentRenderer.cfc and it will be available via $.dspSWF().
<!---
Add this to html_head.cfm
<script type="text/javascript" src="#$.siteConfig('assetPath')#/js/swfobject/swfobject.js"></script>
Example Usage:
#$.dspSWF(swf='#$.siteConfig('themeAssetPath')#/assets/yourfile.swf', width=680, height=100, objectID='your-file', wrapperID='your-file-wrapper')#
--->
<cffunction name="dspSWF" output="false" returntype="any">
<cfargument name="swf" default="" />
<cfargument name="width" default="100" />
@stevewithington
stevewithington / parseMuraColor.cfm
Last active April 20, 2016 22:38
Mura CMS : Mura allows you to create an extended attribute to collect a color value via a color picker. The value is stored as: rgba(x,x,x,1). You can use a number of methods to extrapolate this value into other formats as needed. Keep in mind though, that most modern browsers allow for CSS3 color values (http://caniuse.com/css3-colors), so you …
<!--- drop these methods into your Site or Theme contentRenderer.cfm --->
<cfscript>
// props: http://cflib.org/udf/RGBtoHex
public any function RGBtoHex(r,g,b){
var hexColor = '';
var hexPart = '';
var i = 0;
for (i=1; i <= 3; i++){
hexPart = FormatBaseN(arguments[i],16);
<!--- if using CFStatic --->
<cf_CacheOMatic key="isotopeCSS">
#$.static()
.include('/css/isotope/')
.renderIncludes('css')#
</cf_CacheOMatic>
<!--- Static CSS Include --->
<!--- <link rel="stylesheet" href="#$.siteConfig('themeAssetPath')#/css/isotope/isotope.css"> --->
@stevewithington
stevewithington / ajaxData.cfc
Last active November 27, 2018 19:20
Mura CMS : jQuery Ajax example. Sometimes, you'll need to access a file via Ajax in Mura. Some key things to keep in mind are 1) You cannot directly access a .cfm file located under a SiteID unless a) it resides in a directory called 'remote' [as of v6.1], or b) You edit the file located under /{SiteID}/includes/Application.cfc on approximately …
<cfscript>
// Save this file to a path such as /{SiteID}/includes/themes/{ThemeName}/remote/ajaxData.cfc
component {
remote string function getData(siteid='default', contentid='00000000000000000000000000000000001') returnformat='plain' {
var str = '';
var $ = get$(arguments.siteid, arguments.contentid);
savecontent variable='str' {
WriteOutput("<h1>Hello from ajaxData.cfc</h1>
@stevewithington
stevewithington / muraUserFeed.cfm
Last active January 3, 2016 21:49
Mura CMS : Example of how to create a user feed bean and loop over the user iterator to output data and extended attributes.
<cfscript>
// USER feed bean
userFeed = $.getBean('userFeed');
// if user(s) belong to a different site, specify desired siteid
// userFeed.setSiteID('someSiteID');
// if you know the groupid, you can filter that
// userFeed.setGroupID('someGroupID', false);