CF Coding Practices
  • General Coding Practices
  • Debugging JSON-based CFC Methods
    • Valid JSON Formatting
    • Validating JSON
    • Final Hints
  • How We Invoke Modals
  • Submit Handlers
  • Useful SQL Snippets
  • jQuery/JS How-Tos And Hints
  • jQuery dataTables Tricks
  • CFSCRIPT Snippets and Hints
  • StatusPage Integration
  • Windows Server Setup
  • Common CF Formatting Commands
  • CF Snippets & Hints
  • Developing With The Mura Platform
    • ContentRenderer.CFC
    • Iterators
    • Iterating Remote Feeds
    • Components
    • Nested Content and Interactive Page Assembly
    • Modules and Display Objects
Powered by GitBook
On this page
  • Content
  • Images
  • Loading the Content Bean
  • SiteConfig Content Subscope
  • Handling Custom Events
  • Determining Available Information Fields

Was this helpful?

Developing With The Mura Platform

This is a general guide to the process of deploying websites with Mura CMS 7.1

CF Foundry uses the Mura CMS platform for deploying many websites and web applications. Mura provides a modular development framework that includes an integrated CMS that is user friendly and offers inline page editing for those clients that maintain their own websites and do not have HTML coding experience.

While BlueRiver (the creators and maintainers of the Mura open-source platform) provides documentation for web developers, content managers, and template creators, the documentation generally only provides a starting point for deploying an application and leaves a lot undocumented. This is particularly true with specific examples for high-level actions (such as adding a blog to a site) as well as lower-level examples, such as how to use iterators in various situation, best practices, etc.

Much of the additional information on how to develop with the Mura platform is distributed across various blog entries and BlueRiver's Google support channel. The documentation provided here is an aggregation of this available documentation and internally-generated information.

Content

Content for page on websites created with Mura is typically populated by combining user-entered data in the Mura CMS with templates created in CFML (.cfm files). For example, to add a page to a Mura-driven website, users would typically use the Mura CMS to add a page in the CMS, entering any text that they desired to be displayed on the page and associated a page template with the page. The template then fetches and displays the information using the Mura Content bean/subscope. This is a very overly simplistic view of what can be done to create content on a Mura website and ignores all of the advanced features of the CMS, plugins, dynamically generated pages & content, etc., but suffices for explaining how we access data from the Mura CMS and display it.

$.content('body') //Gets the body content for the page, folder, etc.
$.content('title') //Gets the title of the page, folder, etc.

In the above example, the "body" and "title" attributes are fed to the content bean to fetch the associated data. The content bean is a very robust component of the Mura CMS framework and can (as of version 7.1) provide all of the following data:

Attribute

Description

active

Whether the content item is active.

approvalchainoverride

Whether to ignore approval chain, if applied.

approvalgroupid

The current approval chain GroupID the content item is assigned to.

approvalstatus

The approval status of the content item.

approved

Whether the content item is approved.

assocfilename

The name of the file of the primary associated image/file.

body

The main content/body of the content item.

categoryid

A comma-delimited list of CategoryIDs associated with the content item.

changesetid

The ChangeSetID the specific content item version is associated with, if any.

childtemplate

Default template to be applied to children, if any.

contenthistid

A unique identifier for the specific version of the content item.

contentid

A unique identifier for the content item.

created

Date/time the content was originally created.

credits

The credits field of the content item. Similar to a byline.

depth

A numeric representation of number of levels deep the content item resides in relation to the "Home" page.

display

Whether to display the content item.

displayinterval

If "display" is set to "Per Schedule", a JSON-encoded string representing the scheduled display interval.

displaystart

If "display" is set to "Per Schedule", the date/time to begin displaying the content item.

displaystop

If "display" is set to "Per Schedule", the date/time to stop displaying the content item.

expires

The content expiration date field of the content item.

featurestart

If the content item is featured, the date/time to begin featuring it.

featurestop

If the content item is featured, the date/time to stop being featured.

fileext

The file extension of the primary associated image/file.

fileid

The FileID of the primary associated image/file.

filename

The URL to the content item, excluding the domain name.

filesize

The file size of the primary associated image/file.

htmltitle

The HTML Title field of the content item.

imageheight

If the content item is a Folder, and imagesize is "custom" the height in pixels to use for images.

imagesize

If the content item is a Folder, the pre-defined size to use for images (e.g., small, medium, large, custom, etc.)

imagewidth

If the content item is a Folder, and imagesize is "custom", the width in pixels to use for images.

inheritobjects

Whether the content item is inheriting display objects from an ancestor.

isfeature

Whether the content item is featured in the section.

ishome

Whether the content item is the "Home" page.

islocked

Whether the content item is locked, if type is a file.

isnav

Whether the content item should be shown in navigational objects generated by Mura.

isnew

Whether the content item is new.

lastupdate

The date/time the content item was last updated.

lastupdateby

The name of the user who last updated the content item.

lastupdatebyid

The UserID of the user who last updated the content item.

majorversion

The major version number of the content item, if type is a file.

menutitle

The Menu Title field of the content item.

metadesc

The Meta Description of the content item.

metakeywords

The Meta Keywords of the content item.

minorversion

The Minor Version of the content item, if the type is a file.

mobileexclude

Whether to exclude the content item from navigation objects on mobile devices.

moduleassign

If content type is a Form or Component, a comma-delimited list of ModuleIDs of modules to allow the Form/Component to be used in. Essentially, the answer to the "Where would you like to use this Component?" question.

moduleid

ModuleID of the content item.

newfile

This is the field you set new primary associated files, when creating new content programatically.

nextn

If content type is a Folder, the number of records to display on each page.

notes

The Notes field of the content item.

objectparams

The objectparams of the content item.

orderno

The Order Number of the content item, if the parent is using "Manual" sort.

parentid

The ContentID of the direct parent of the content item.

path

A comma-delimited list of ContentIDs representing the ancestry of the content item.

releasedate

The Official Release Date field of the content item.

remoteid

A special field for developer's to use. May load the content item by this field. It does not have to be unique. Typically, used to store a unique identifier to associate the content item to an external data store.

remotepubdate

A special field for developer's to use when importing or associating content to an external data store.

remotesource

A special field for developer's to use when importing or associating content to an external data store. Typically, the name of the external data.

remotesourceurl

A special field for developer's to use when importing or associating content to an external data store. Typically, the domain of the external data.

remoteurl

A special field for developer's to use when importing or associating content to an external data store. Typically, the full URL to the external content.

restricted

Whether the content item is restricted.

restrictgroups

A comma-delimited list of GroupIDs to restrict access to.

searchexclude

Whether to exclude the content item from Mura's search results.

siteid

The SiteID the content item is associated with.

sortby

If content type is Folder, which field to sort by.

sortdirection

If content type is Folder, which direction to sort by.

status

The Status of the content item (e.g., Published, Draft, etc.).

statusid

The StatusID of the content item.

subtype

Subtype of the content item.

summary

The Summary field of the content item.

tags

A comma-delimited list of default tags.

target

Whether to open in a new browser window.

template

The layout template applied directly to the content item. If empty, Mura will traverse up the tree until it locates an applied template, and if none are found or the applied template is not found, will use the default.cfm layout template.

title

The main Title field of the content item.

type

The type of the content item (e.g., Page, Folder, Calendar, Link, File, etc.)

urltitle

The URL Title field of the content item.

Images

As with many things, there are several different ways to get images/image content from Mura. Each of these are outlined below.

getImageURL()

The getImageURL() function is available in the content subscope for the current page, as well as the iterator object:

getImageURL() Example
<!--- Fetch image for current page with a size of "header" --->
<img src="$.content().getImageURL(size='header')#"/>

<!--- Fetch image associated with an interator object --->
<cfset feed=$.getBean('feed').loadBy(name="Home Page Slider")>
<cfset slides=feed.getIterator()>
<cfif iterator.hasNext()>
    <cfloop condition="slides.hasNext()">
	    <cfset slide = slides.next()/>
		<img src="#slide.getImageURL()#"/>
		...

createHREFForImage()

The createHREFForImage() function provides a great way to fetch an image that was added to a page, component, etc. as an extended class attribute.

createHREFForImage() Example
<!--- Page Template --->
$.createHREFForImage(fileid = $.content().getValue('extAttributeImage'))

<!--- Mura component extended attribute --->
#$.createHREFForImage(filename=$.component('extAttributeImage'),size='myCustomSize')#

<!--- In the context of an iterator --->
<cfset feed=$.getBean('feed').loadBy(name="Home Page Slider")>
<cfset slides=feed.getIterator()>
<cfif iterator.hasNext()>
    <cfloop condition="slides.hasNext()">
	    <cfset slide = slides.next()/>
		<img src="#$.createHREFForImage(filename=slide.getValue('extAttributeImage'),size='myCustomSize')#"/>
		...

getURLForImage()

This function is used exclusively to fetch an image based on its file ID. You must specify the file ID to use this function and it supports numerous other parameters as well (see current Mura documentation for other parameters).

getURLForImage() Example
<!--- Get image for current page if it exists --->
<cfif Len(m.getURLForImage(fileid=$.content('fileid')))>
    <img src="#m.getURLForImage(fileid=$.content('fileid'), size='medium')#">
</cfif>

Loading the Content Bean

Additionally, you can apply the .getAllValues() to the content subscope object (as with other beans like siteConfig, glocalConfig, currentUser, event, etc.) as follows: $.content().getAllValues().

When you use the content subscope, it will default to fetching data for the current page, folder, etc. However, you can override this behavior to get data for other items in the CMS, by specifying different attributes:

  • contentid

  • contenthistid

  • filename

  • remoteid

  • title

  • urltitle

For example, to fetch the page or folder body for a page with a title of "services":

$.content('title').loadBy(title='services')

NOTE: Using the "$.content()" syntax is shorthand for $.getBean('content') as "content" is a subscope/object wrapper of the Mura Scope "$". You could also use $.content().get('title') or $.content().getValue('title')

SiteConfig Content Subscope

The siteConfig() content subscope is home to site settings and is a wrapper to Mura's site bean object. As with other content subscopes, it supports getter and setter objects for retrieving and setting data.

We typically use the siteConfig() subscope to access site settings entered through the Mura admin, such as contact information (address, sity, state, phone, email address, etc.) associated with the website itself.

<!--- Getting site contact information --->
<li>
	<span class="pi-bullet-icon"><i class="icon-location"></i></span>
	<strong>Address:</strong> #$.siteConfig('contactAddress')#<br />
	#$.siteConfig('contactCity')#, #$.siteConfig('contactState')#, #$.siteConfig('contactZip')#
</li>
<li>
	<span class="pi-bullet-icon"><i class="icon-phone"></i></span>
	<strong>Phone:</strong> #$.siteConfig('contactPhone')#
</li>
<li>
	<span class="pi-bullet-icon"><i class="icon-mail"></i></span>
	<strong>Email:</strong> #$.siteConfig('contactEmail')#
</li>
<li>
	<span class="pi-bullet-icon"><i class="icon-clock"></i></span>
	<strong>Hours of Operation:</strong><br />#$.siteConfig('hoursOfOperation')#
</li>

The following table identifies the available attributes for the siteConfig and site bean object:

Attribute

accountactivationscript

addobjects

admanager

advertiseruserpoolid

baseid

cache

cachecapacity

cachefactories

cachefreememorythreshold

categorypoolid

columncount

columnnames

commentapprovaldefault

contact

contactaddress

contactcity

contactemail

contactname

contactphone

contactstate

contactzip

contentapprovalscript

contentcanceledscript

contentpendingscript

contentpoolid

contentrejectionscript

contentrenderer

contenttypefilepathlookup

contenttypeloopuparray

customtaggroups

datacollection

deploy

displayobjectfilepathlookup

displayobjectlookup

displayobjectloopuparray

displaypoolid

domain

domainalias

editprofileurl

emailbroadcaster

emailbroadcasterlimit

enablelockdown

enforcechangesets

enforceprimarydomain

errors

exportlocation

extendautocomplete

extenddata

extenddatatable

extendsetid

extranet

extranetpublicreg

extranetpublicregnotify

extranetssl

feedmanager

filepoolid

frommuracache

googleapikey

haschangesets

hascomments

haslockablenodes

hassharedfilepool

instanceid

isnew

isremote

javalocale

jsdatekey

jsdatekeyobjinc

jsonapi

largeimageheight

largeimagewidth

lastdeployment

locking

loginurl

mailinglistconfirmscript

mailserverip

mailserverpassword

mailserverpopport

mailserversmtpport

mailserverssl

mailservertls

mailserverusername

mailserverusernameemail

mediumimageheight

mediumimagewidth

nextn

orderno

pagelimit

placeholderimgext

placeholderimgid

primarycolumn

privateuserpoolid

publicsubmission

publicsubmissionapprovalscript

publicuserpoolid

rbfactory

recaptchalanguage

recaptchasecret

recaptchasitekey

reminderscript

remotecontext

remoteport

resourcedomain

resourcessl

sendauthcodescript

sendloginscript

showdashboard

site

siteid

sitelocale

smallimageheight

smallimagewidth

sourceiterator

subtype

tagline

theme

themelookup

themerenderer

type

usedefaultsmtpserver

usessl

viewdepth

Handling Custom Events

Steve Withington wrote a nifty little example of how to handle a custom even in Mura. In this case, it is an example of a form submission. In this example, a simple form with a unique hidden field is created and code is then added to the eventHandler.cfc to listen for and handle the form submission.

<!--- 1) Create a form with a hidden form field like shown below, and place it in a layout template, or in a display object, etc. --->
<form method="post">
	<input type="text" name="myField" value="Some Value">
	<input type="hidden" name="myFormIsSubmitted" value="true">
	<input type="submit">
</form>

<cfscript>
  // 2) In the eventHandler.cfc (Site, Theme, Plugin, or other custom handler) you could listen for the even in one of Mura's eventHandlers such as 'onRenderStart'
  public any function  onRenderStart(event, m){
    if ( arguments.event.get('myFormIsSubmitted') == 'true' ){ 
      arguments.m.announceEvent('CustomFormSubmitted');  
    }
  }

  // 3) In the eventHandler.cfc (Site, Theme, Plugin, or other custom handler) you could then have your custom event
  public any function onCustomFormSubmitted(event, m) {
    // do something here
    WriteDump(var=arguments.event.get('myField), abort=true);
    // OR, WriteDump(var=arguments.event.getAllValues(), abort=true);
  }
</cfscript>

Determining Available Information Fields

As well documented as Mura is, it still lacks a lot of practical documentation on how to specifically do certain tasks, access certain data, etc. For example, if you wanted to get a URL for a file that is uploaded as part of the Mura File content type (Mura has different content types like Page, Folder, File, Gallery, etc), how would you do that?

Navigating your way through the API documentation can sometimes yield the information that you need, but as mentioned in the "Loading the Content Bean" section above, using the getAllValues() function is also highly useful. Whenever accessing a Mura object, such as $.content().getAllValues() or an iterator object (e.g. #item.getAllValues()#). So, for our example of getting the file URL for the file associated with a File content type, we could do the following:

<!--- Where 'download' is an interator object Next() value: --->
<a href="#$.getURLForFile(fileID=download.getValue('fileID'))#" target="_blank">
    #download.getValue('title')#
</a>

NOTE: When using getAllValues(), it will output a complex object data type (structure), so you will need to use writeDump()/<cfdump> to output the content as follows:

<cfdump var="#$.content().getAllValues()#"/>
- or -
<cfscript>
    writeDump($.content().getAllValues());
</cfscript>

PreviousCF Snippets & HintsNextContentRenderer.CFC

Last updated 5 years ago

Was this helpful?

NOTE: All Mura objects/beans are well documented in terms of their functions and parameters via Mura's live API documentation. For example, information about the content bean for Mura 7.1 is available at:

https://www.getmura.com/component-api/7.1/mura/content/contentBean.html