Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mattlevine/01529dbfa7c439cc706873c328e48601 to your computer and use it in GitHub Desktop.
Save mattlevine/01529dbfa7c439cc706873c328e48601 to your computer and use it in GitHub Desktop.
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');
}
// open calendar events in a blank template
if ( Right($.content('parentid'),3) != 'END' && $.content().getParent().getType() == 'Calendar' && $.content('type') == 'Page' ) {
$.content('template','blank.cfm');
}
}
}
<cfdocument format="pdf">
<cfoutput>
<h3>#HTMLEditFormat($.content('title'))#</h3>
#$.dspBody(body=$.content('body'),pageTitle='',crumbList=0,showMetaImage=0)#
</cfoutput>
</cfdocument>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment