Skip to content

Instantly share code, notes, and snippets.

View sebgmc's full-sized avatar

Sebastiaan van Dijk sebgmc

View GitHub Profile
@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 / 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 / muraGetFileORImageByFileID.cfm
Created August 16, 2013 20:07
Mura CMS : Mura has two different methods for get a link to a file stored as an extended attribute. The one you choose depends on if you're expecting the file to be an "image" or a "file" ... if it's not a valid image or file, then the methods will return an empty string, which means you can test for the return value and then output it if it exi…
<cfscript>
// simple examples
fileURL = $.getURLForFile('yourFileID');
imageURL = $.getURLForImage('yourFileID');
</cfscript>
<!--- File Example --->
<cfif Len($.getURLForFile($.content('myCustomAttribute')))>
<a href="#$.getURLForFile($.content('myCustomAttribute'))#">Download File</a>
<cfelse>
@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 / 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 / muraRandomRelatedContent.cfm
Last active September 11, 2020 11:20
Mura CMS: a "Related Content" iterator and query/recordset sorted randomly
<cfscript>
listSortBy = 'menutitle,title,lastupdate,releasedate,orderno,displaystart,displaystop,created,credits,type,subtype';
listSortDir = 'asc,desc';
sortby = ListGetAt(listSortBy, RandRange(1, ListLen(listSortBy), 'SHA1PRNG'));
sortdir = ListGetAt(listSortDir, RandRange(1, ListLen(listSortDir), 'SHA1PRNG'));
rsRelated = $.content().getRelatedContentQuery(sortby=sortby, sortDirection=sortdir);
itRelated = $.getBean('contentIterator').setQuery(rsRelated);
</cfscript>
<!---