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 / muraImportContentFromRSS.cfm
Last active January 15, 2024 14:29
Mura CMS: Example of how to import content into Mura CMS from an RSS feed. Place the file under your Mura root. For example: http://yourdomain.com/temp/import/index.cfm. Also see https://gist.github.com/stevewithington/5051646 to importUsersViaCSV
<cfscript>
param name='form.rssurl' default='http://www.npr.org/rss/rss.php?id=1014';
param name='form.parentfilename' default='blog';
param name='form.isSubmitted' default='false';
param name='form.istest' default='true';
param name='form.siteid' default='default';
$ = application.serviceFactory.getBean('$').init(form.siteid);
if ( !$.currentUser().isSuperUser() && !$.currentUser().isInGroup('admin') ) {
@stevewithington
stevewithington / muraImportUsersViaCSV.cfm
Last active January 19, 2024 09:02
Example of how to import Users into Mura CMS via .CSV file. Also see https://gist.github.com/stevewithington/4742829 to import content from an RSS Feed.
<cfscript>
param name='form.csvUrl' default='#getPageContext().getRequest().getScheme()#://#cgi.server_name##getDirectoryFromPath(getPageContext().getRequest().getRequestURI())#users.csv';
param name='form.group' default='Temp';
param name='form.isSubmitted' default='false';
param name='form.isTest' default='true';
param name='form.siteid' default='default';
$ = application.serviceFactory.getBean('$').init(form.siteid);
if ( !$.currentUser().isSuperUser() && !$.currentUser().isInGroup('admin') ) {
@stevewithington
stevewithington / muraHTACCESSFile
Last active December 1, 2023 17:45
Mura CMS .htaccess & web.config file. This shows an example of how to include SiteIDs for specific sites, and allow for some sites to not have the SiteID in the URL.
# Also refer to https://gist.github.com/stevewithington/5060602 if you wish to allow for mixed siteIDs in URLs
# Apache mod_rewrite Docs: http://httpd.apache.org/docs/current/rewrite/
# Intro: http://httpd.apache.org/docs/current/rewrite/intro.html
# Flags: http://httpd.apache.org/docs/current/rewrite/flags.html
Options All -Indexes
Options +FollowSymLinks
# -------------------------------------------------------------------------------
# MURA REWRITE OPTIONS
<cfcomponent extends="mura.content.contentRenderer">
<!---
Add this method to the contentRendrer.cfc of any Site you wish to HAVE the SiteID in the URL.
Also refer to https://gist.github.com/stevewithington/5060589 for rewrite rules needed!!
--->
<cfscript>
// Drop these methods into your Site's contentRenderer.cfc for the sites that you WANT SiteIDs in URL
public string function getURLStem(required siteid, filename='') {
var sid = '/' & arguments.siteid;
<!--- This method would reload the application at the time it's executed --->
<cflocation url="./?#URLEncodedFormat(application.appreloadkey)#&reload=#URLEncodedFormat(application.appreloadkey)#" addtoken="false" />
<!--- OR --->
<!--- This method would force Mura to reload on the next event --->
<cfset application.appinitialized = false>
@stevewithington
stevewithington / muraAddUserToMailingList.cfm
Last active December 15, 2015 00:38
Easily add existing Mura CMS users to a Mailing List.
<cfsilent>
<cfscript>
// MailingListBean (if you don't know the MLID, but you know the ListName)
mlid = $.getBean('mailinglistBean').loadBy(
name='Mailing List Name Goes Here'
, siteid=$.siteConfig('siteid')
).getMLID();
//mlid = '6013C140-FD78-B5D9-60A468E7D2B5D6F0';
@stevewithington
stevewithington / muraDynamicLayoutTemplate.cfc
Last active April 27, 2018 19:24
Mura CMS: dynamically change layout templates (e.g., Allow for a "View As PDF" link, or only open children of a calendar in a blank.cfm layout template ... this way you could open it in a modal window using shadowboxjs, etc.)
component extends='mura.cfobject' {
// drop this in your site or theme eventHandler.cfc
public any function onRenderStart($) {
// allow for a 'View As PDF' link (e.g., <a href="./?viewAsPDF=1">View As PDF</a>)
if ( IsBoolean(arguments.$.event('viewAsPDF')) && arguments.$.event('viewAsPDF') ) {
arguments.$.content('template', 'pdf.cfm');
}
@stevewithington
stevewithington / muraCustomErrorFile.cfm
Last active January 19, 2024 08:52
Mura Error Handling: You could use any or even both of the attached methods to help with error handling in Mura CMS. This works better than the default "We're sorry, an error has occurred. Please try again later."
<!---
1) Drop this file under /config/ directory.
2) Add errortemplate=/muraWRM/config/customErrorFile.cfm to the settings.ini.cfm file.
3) Set debuggingenabled=false in the settings.ini.cfm file.
4) Reload Mura CMS
--->
<cftry>
<cfset msg = 'MURA ERROR - MESSAGE: #arguments.exception.Message# DETAIL: #arguments.exception.Detail# ' />
<cflog type="ERROR" file="MuraError" text="#msg#" />
<cfcatch></cfcatch>
@stevewithington
stevewithington / muraTracePointExample.cfm
Created April 18, 2013 15:47
Mura CMS : Create a Custom Trace Point. To view, login as an admin, then append your URL with ?showTrace=1. A Stack Trace with the duration and running total of milliseconds should appear in a list format. To disable, append your URL with ?showTrace=0
<!--- Place this either at the top of your file, or at the beginning of a block of code you wish to trace --->
<cfset myTracePoint = $.initTracePoint('yourFilenameOrOtherDescriptionToIdentifyThisTracePointGoesHere') />
<!--- file content or block of code goes here --->
<!--- Place this either at the bottom of your file, or at the end of a block of code you wish to trace --->
<cfset $.commitTracePoint(myTracePoint) />
@stevewithington
stevewithington / onSiteCKFinderConfig.cfm
Last active December 17, 2015 03:18
Mura CMS : Programmatically allow CKFinder to accept new file extensions.
<cfscript>
// drop this in your eventHandler.cfc
public void function onSiteCKFinderConfig($) {
var config = arguments.$.event('config');
for (var i=1; i LTE ArrayLen(config.resourceType); i++){
config.resourceType[i].allowedExtensions = ListAppend(config.resourceType[i].allowedExtensions,'abc');
}
arguments.$.event('config',config);
}
</cfscript>