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 / muraCreatePageAndUser.cfm
Created October 17, 2014 21:51
Mura CMS : Example of how to create a content item when updating a User
<cfscript>
public any function onAfterUserSave($) {
// reference to new user bean
var user = arguments.$.event('userBean');
// reference to old user bean
//var oldUserBean = arguments.$.getBean('user').loadBy(userid=user.getUserID());
// reference to content item that will be the parent of the 'User' page
var parentbean = $.getBean('content').loadBy(title='Reps');
@stevewithington
stevewithington / muraGetUpcomingEventsByFeedname.cfm
Last active September 18, 2018 12:48
Mura CMS : Example of how to get upcoming calendar events by Feed name
<!---
https://gist.github.com/stevewithington/18a6ef38e7234f1e1fc3
1) Drop this in your Site or Theme contentRenderer.cfc
2) To use, drop the following line of code in your layout template, and modify as you wish:
#$.getUpcomingEventsByFeedname(feedname='Your Feed Name', maxMonths=2, groupDailyEvents=true)#
--->
<cffunction name="getUpcomingEventsByFeedname">
<cfargument name="feedName" type="string" required="true" />
<cfargument name="maxMonths" type="numeric" default="3" />
<cfargument name="groupDailyEvents" default="true" />
@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 / muraImageSizes.cfm
Last active August 29, 2015 14:06
Mura CMS : How to get the custom and default image sizes for a site.
<cfscript>
// recordset
rsCustomSizes = $.siteConfig().getCustomImageSizeQuery();
// iterator
itCustomImageSizes = $.siteConfig().getCustomImageSizeIterator();
// OR, drop this in your contentRenderer.cfc, and access via $.getImageSizeQuery()
public any function getImageSizeQuery() {
var rs = variables.$.siteConfig().getCustomImageSizeQuery();
@stevewithington
stevewithington / cfmail-test.cfm
Last active July 13, 2022 22:05
CFMail Test File
<!---
// For GMAIL accounts:
server=smtp.gmail.com
port=465
useSSL=yes
--->
<cfparam name="form.message" default="Test" />
@stevewithington
stevewithington / muraImportFiles.cfm
Last active December 2, 2020 10:39
Mura CMS : How To Import A Directory Of Files Into Mura As Content Items
<cfscript>
// This will NOT work unless you have 'allowlocalfiles=true' in /config/settings.ini.cfm
// example path to files
try {
filepath = ExpandPath('./files');
} catch(any e) {
filepath = ExpandPath('./');
}
@stevewithington
stevewithington / muraSaveFile.cfm
Last active August 29, 2015 14:06
Mura CMS : How to Dynamically Add Files As Content Items.
<cfscript>
// Will NOT work unless you have 'allowlocalfiles=true' in /config/settings.ini.cfm
try {
filepath = ExpandPath('temp.pdf');
} catch(any e) {
filepath = '';
}
param name='form.thefile' default=filepath;
@stevewithington
stevewithington / muraGetAssociatedImageMetaData.cfm
Created September 10, 2014 00:23
Mura CMS: How to get the primary associated image metadata such as AltText, Caption, Credits, etc.
<cfset itKids = $.content().getKidsIterator() />
<cfif itKids.hasNext()>
<ul>
<cfloop condition="itKids.hasNext()">
<li>
<cfscript>
item = itKids.next();
fileid = item.getValue('fileid');
if ( item.hasImage() ) {
@stevewithington
stevewithington / muraSaveImage.cfm
Last active June 20, 2024 10:51
Mura CMS : How To Dynamically Add Images or Photos To Content Items
<cfscript>
// This will NOT work unless you have 'allowlocalfiles=true' in /config/settings.ini.cfm
// read image info on local file for default value
try {
ir = ImageRead('steve-withington.jpg');
img = ir.source;
} catch(any e) {
img = '';
}
@stevewithington
stevewithington / muraGroupCalendarEvents.cfm
Last active April 27, 2018 19:16
Mura CMS : Example of how to group Mura CMS calendar events together. Another example can be found at https://gist.github.com/stevewithington/18a6ef38e7234f1e1fc3
<!--- See https://gist.github.com/stevewithington/18a6ef38e7234f1e1fc3 for a better example! --->
<cfscript>
it = $.getBean('feed').loadBy(name='Your Feed Name').getIterator(
from=Now()
, to=DateAdd('m', 2, Now())
);
rs = $.getCalendarUtility().filterCalendarItems(it.getQuery(),0);
</cfscript>
<ul>
<cfoutput query="rs" group="contentid">