Skip to content

Instantly share code, notes, and snippets.

<section>
<h2>Mura CMS</h2>
<cffeed query="rs" source="http://www.getmura.com/tasks/feed/?feedID=91B4E7A5-37AC-466A-ACDF6ABFD95ACCBD" />
<cfset it = $.getBean('beanIterator').setQuery(rs) />
<ul>
<cfif it.hasNext()>
<cfloop condition="it.hasNext()">
<cfset item = it.next()>
<li>
<a href="#item.getValue('rsslink')#">
<!--- drop this file under the theme's display_objects directory --->
<cfoutput>
<form id="login" class="form-horizontal" name="frmLogin" method="post" action="?nocache=1" onsubmit="return validate(this);" novalidate="novalidate" >
<legend>#arguments.$.rbKey('user.pleaselogin')#</legend>
<div class="control-group">
<label class="control-label required" for="txtPassword">#arguments.$.rbKey('user.password')#</label>
<div class="controls">
<input type="password" id="txtPassword" name="password" placeholder="#arguments.$.rbKey('user.password')#" required="true" message="#htmlEditFormat(arguments.$.rbKey('user.passwordrequired'))#" />
<span class="help-inline">#htmlEditFormat($.rbKey('user.required'))#</span>
</div>
<cfscript>
rsChildTags = $.getBean('contentGateway').getTagCloud(
siteid = $.event('siteid')
, parentid = $.content('contentid')
, categoryid = $.event('categoryid')
, taggroup = '' // could narrow down to a specific tag group as of 6.1
);
WriteDump(var=rsChildTags, label='rsChildTags');
<cfscript>
// Save this file to a path such as /{SiteID}/includes/remote/ajaxData.cfm
// This allows you to pass in the siteid and contentid via URL params
param name='url.siteid' default='default';
param name='url.contentid' default='00000000000000000000000000000000001';
// Mura $cope
$ = application.serviceFactory.getBean('$').init(url.siteid);
// Just in case we need access to the ContentBean
cBean = $.getBean('content').loadBy(contentid=url.contentid);
$.setContentBean(cBean);
<cfscript>
// Drop this in your Site or Theme eventHandler.cfc
public any function onBeforeFormSubmitSave($) {
// reference to the formBean
var formBean = arguments.$.event('formBean');
// example on how to create some errors
var error = '';
var errors = {};
<cfscript>
// drop this in your eventHandler.cfc
public any function yourMethod() {
// you do something here
}
public any function onApplicationLoad($) {
arguments.$.getBean('someBean').injectMethod('someMethod', yourMethod);
}
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');
}
<!--- Drop this into your site eventhandler.cfc --->
<cffunction name="onAfterFormSubmitSave" output="true">
<cfif $.event('formid') EQ '{ID of the Mura form}'>
<!--- Get the form result --->
<cfset formBean = $.event().getValue('formresult')>
<!--- Get a new content bean --->
<cfset cBean = application.contentManager.getBean()>
<!--- Set the new node attributes --->
<cfset cBean.setSiteID($.event('siteid'))>
<cfscript>
// Place these methods in your Site, Theme, or Plugin's eventHandler.cfc
public any function onBeforeUserSave($) {
var newUserBean = arguments.$.event('userBean');
var oldUserBean = arguments.$.getBean('user').loadBy(userid=arguments.$.event('userid'));
// if you want to stuff the oldUserBean in the event
// $.event('oldUserBean', oldUserBean);
<!--- 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($){