Skip to content

Instantly share code, notes, and snippets.

@mattlevine
mattlevine / mura-dspDescendants.cfm
Created April 27, 2018 19:07 — forked from stevewithington/mura-dspDescendants.cfm
Mura CMS: How to create custom navigation with permissions applied, based on a contentID and its children.
<!---
Place this function in your Site or Theme contentRenderer.cfc
Invoke by calling `$.dspDescendants()`
--->
<cffunction name="dspDescendants">
<cfargument name="contentid" type="string" default="#$.content('contentid')#" />
<cfset var local = {} />
<cfset local.cBean = $.getBean('content').loadBy(contentid=arguments.contentid) />
<cfsavecontent variable="local.str">
@mattlevine
mattlevine / mura-ckeditor-image-options.js
Created April 27, 2018 19:08 — forked from stevewithington/mura-ckeditor-image-options.js
Mura CMS: CKEditor has 2 image plugins, and you can easily use either of them on a theme-by-theme basis.
/*
There are two (2) image plugins available for CKEditor:
The "Image" plugin (https://ckeditor.com/cke4/addon/image), which is used by default;
and the "Enhanced Image" plugin (https://ckeditor.com/cke4/addon/image2), which offers the ability to caption images.
To enable the "Enhanced Image" plugin, follow these instructions:
1. Edit the file located under {ThemeName}/js/editor/config.js.cfm
(if the file doesn't exist, create it ... if the config.js.cfm.txt file exists, rename it to remove '.txt')
@mattlevine
mattlevine / mura-html-editor-word-character-count.js
Created April 27, 2018 19:08 — forked from stevewithington/mura-html-editor-word-character-count.js
Mura CMS: How to add word count and character count to HTML Editors
/*
There's an elegant way to restrict character or word count in Mura CMS HTMLEditors.
1. Download the Word Count & Char Count Plugin:
https://ckeditor.com/cke4/addon/wordcount
2. Download the Notification plugin:
https://ckeditor.com/cke4/addon/notification
3. Unzip the the plugins and add the directories to the CKEditor plugins directory:
@mattlevine
mattlevine / mura-head-meta-og.cfm
Created April 27, 2018 19:08 — forked from stevewithington/mura-head-meta-og.cfm
Mura CMS: Sample Open Graph Meta Tags for a Mura CMS Website
<!--- Open Graph (http://ogp.me) --->
<meta property="og:site_name" content="#esapiEncode('html_attr', m.siteConfig('site'))#" />
<meta property="og.locale" content="#m.siteConfig('javalocale')#" />
<meta property="og:title" content="#esapiEncode('html_attr', m.content('title'))#" />
<meta property="og:type" content="website" />
<meta property="og:url" content="#m.createHref(filename=m.content('filename'), complete=true)#" />
<cfif Len(m.getURLForImage(fileid=m.content('fileid')))>
<meta property="og:image" content="#m.getURLForImage(fileid=m.content('fileid'), size='large', complete=true)#" />
</cfif>
<cfif Len(m.content('metadesc'))>
@mattlevine
mattlevine / onContentEditMessageRender.cfm
Created April 27, 2018 19:09 — forked from stevewithington/onContentEditMessageRender.cfm
Mura CMS: Admin Alert & Help Block Messages
<cfscript>
// add to an event handler
public any function onContentEditMessageRender(event, m) {
// reference to the event, if needed
var e = arguments.event;
// could also get a reference to event via Mura Scope
var mse = arguments.m.event();
// this example merely shows how to render a simple message
@mattlevine
mattlevine / component_index.cfm
Created April 27, 2018 19:09 — forked from stevewithington/component_index.cfm
Mura CMS: How to enable editable components in Mura 7 similar to how they worked in Mura 6.
<!---
NOTE:
In Mura 6, using '$.dspObject(object='component', objectid='Some Component')' in a layout template
would generate a pencil icon for content manager to edit the component from the front-end view of the site.
In Mura 7, we have migrated to using a layout manager for front-end edits. However, this old functionality no longer works.
So, here's a workaround to accomplish something very similar to the functionality in Mura 6.
1. Under your theme, create a directory labeled 'content_types' if it doesn't already exist
2. Under the 'content_types' directory, create another directory labeled 'component'
@mattlevine
mattlevine / mura-js-form.js
Created April 27, 2018 19:09 — forked from stevewithington/mura-js-form.js
Mura CMS: How to manipulate the DOM of a form in Mura CMS v7+
<script>
Mura.DisplayObject.Form.reopen({
onAfterRender: function() {
//this.context.targetEl is a pointer to the dom element that contains the rendered Mura form.
var container = Mura(this.context.targetEl);
console.log(this.context.targetEl);
}
@mattlevine
mattlevine / primary-nav-with-images.cfm
Created April 27, 2018 19:10 — forked from stevewithington/primary-nav-with-images.cfm
Mura CMS: Custom primary navigation with primary associated images as links.
<!--- Mura 6.2 Syntax (will work in 7.0 as well) --->
<cfset it = $.getBean('feed').addParam(relationship='AND', field='parentid', condition='EQ', criteria='00000000000000000000000000000000001').getIterator() />
<!--- Mura 7.0 Syntax --->
<!--- <cfset it = $.getBean('feed').where().prop('parentid').isEQ('00000000000000000000000000000000001').getIterator() /> --->
<cfif it.hasNext()>
<ul>
<cfloop condition="it.hasNext()">
<cfset item = it.next() />
<li>
<a href="#item.getURL()#">
@mattlevine
mattlevine / mobile-body.cfm
Created April 27, 2018 19:10 — forked from stevewithington/mobile-body.cfm
Mura CMS: Display mobile body vs. regular body content
<!---
Use to display mobile specific content (assumes you have an attribute called 'mobilebody')
--->
<cfset mybody = request.muramobilerequest == 1
&& YesNoFormat(m.content('hasmobilebody'))
&& Len(m.content('mobilebody'))
? m.content('mobilebody')
: m.content('body') />
@mattlevine
mattlevine / muraRebuildImageCache.cfm
Created April 27, 2018 19:10 — forked from stevewithington/muraRebuildImageCache.cfm
Mura CMS: Rebuild image cache or re-save images on redefined image sizes
<!--- Force Image Resave for All Images --->
<cfset application.serviceFactory.getBean('fileManager').rebuildImageCache(siteid='YOURSITEID')>
<!--- or to just reset a specific image size you can use --->
<cfset application.serviceFactory.getBean('fileManager').rebuildImageCache(siteid='YOURSITEID' ,size='YOURSIZE')>