Skip to content

Instantly share code, notes, and snippets.

@mattlevine
mattlevine / mura-custom-form.cfm
Last active June 19, 2018 03:06 — forked from stevewithington/mura-custom-form.cfm
Mura: How to add a validation method to a custom form that doesn't override Mura's async form submission
<!--- Vanilla js --->
<script>
Mura(function(m) {
window.customFormValidation = function(theform) {
// example validation
if (theform.somefield.value === '') {
alert('Please enter a value in somefield');
theform.somefield.focus();
return false;
}
@mattlevine
mattlevine / mura-front-end-toolbar-link.cfm
Created April 27, 2018 19:05 — forked from stevewithington/mura-front-end-toolbar-link.cfm
Mura: How to add a link to the front end toolbar
@mattlevine
mattlevine / mura-recaptcha-example.cfm
Created April 27, 2018 19:05 — forked from stevewithington/mura-recaptcha-example.cfm
Mura: Custom form with Google reCAPTCHA example
<cfparam name="form.issubmitted" default="false"/>
<cfoutput>
<form id="frm-temp" action="" method="post">
<input type="text" name="testing" />
#$.dspReCAPTCHA()#
<button type="submit" class="btn btn-primary">Submit</button>
<input type="hidden" name="issubmitted" value="true"/>
</form>
@mattlevine
mattlevine / mura-form-scripts.js
Created April 27, 2018 19:05 — forked from stevewithington/mura-form-scripts.js
Mura CMS: How to add custom scripts to Mura forms loaded asynchronously
/*
Mura forms are loaded asynchronously. So, if you wish to run some scripts, you need
to use a special method to `reopen` the form, and add your scripts using
`Mura.DisplayObject.Form.reopen({})`
The most commonly needed examples are described below.
*/
@mattlevine
mattlevine / cfapplication.cfm
Created April 27, 2018 19:06 — forked from stevewithington/cfapplication.cfm
Mura: Example external session cache
<cfscript>
this.cache.connections["sessions"] = {
class: 'org.lucee.extension.io.cache.memcache.MemCacheRaw'
, bundleName: 'memcached.extension'
, bundleVersion: '3.0.2.29'
, storage: true
, custom: {
"socket_timeout":"30",
"initial_connections":"1",
"alive_check":"true",
@mattlevine
mattlevine / mura-admin-scripts.cfm
Created April 27, 2018 19:07 — forked from stevewithington/mura-admin-scripts.cfm
Mura CMS: How to add custom scripts (JavaScript, etc.) to the administrative area
<cfscript>
// this example shows how to add custom scripts in the Admin area ...
// you could also use jQuery or whatever other method as well.
// Add this method to a Mura CMS SITE, THEME or PLUGIN eventHandler.cfc
public any function onAdminHTMLFootRender(m) {
var str = '';
savecontent variable='str' {
WriteOutput('
<script>
// Your script goes here.
@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'))>