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 / muraDisableFrontEndTools.cfm
Last active April 27, 2018 19:15
Mura CMS : How to disable front end tools and front end editing for public facing sites. This would then allow you to completely delete/remove the 'admin' directory from the production server, and only host it on a dev/staging server that's hosted behind a firewall, assuming each instance is pointing to the same database. NOTE: Do NOT delete you…
<!---
1) Drop this method in your /config/cfapplication.cfm and modify it as you wish.
For example, maybe you only want to allow front end tools if editing the site behind your firewall
--->
<cfscript>
public boolean function getEnableFrontEndTools() {
return getPageContext().getRequest().getServerName() == 'someURLAccessibleOnlyBehindYourFirewall.com';
}
</cfscript>
@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 / muraCleanFiles.cfm
Created March 31, 2014 16:53
Mura CMS : remove any truly orphaned files from Mura CMS.
<cfset application.serviceFactory.getBean('fileManager').cleanFileCache('[siteid]') />
@stevewithington
stevewithington / config.xml.cfm
Last active December 14, 2023 10:10
Mura CMS : Example of how to create a Frequently Asked Questions (FAQ) area/section with Mura CMS and Bootstrap3 markup.
<!--
1) Drop this in your theme /{SiteID}/includes/themes/{Theme}/config.xml.cfm
-->
<theme>
<extensions>
<extension type="Folder" subType="FAQ" availableSubTypes="Page/Question" iconClass="icon-question-sign">
</extension>
<extension type="Page" subType="Question" iconClass="icon-question" hasSummary="0" hasBody="0" hasAssocFile="0">
</extension>
@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 / 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 / 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 / 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 / dsp_custom_search.cfm
Last active March 19, 2021 16:25
Mura CMS: Custom Search Example
<cfoutput>
<div>
<form action="#$.content('url')#?keywords=#$.event('keywords')#">
<dl>
<dt>Keywords</dt>
<dd><input type="text" name="keywords" value="#HTMLEditFormat($.event('keywords'))#" /></dd>
<dd><input type="submit" value="Search" /></dd>
</dl>