Skip to content

Instantly share code, notes, and snippets.

@stevewithington
Last active April 27, 2018 19:24
Show Gist options
  • Save stevewithington/5197276 to your computer and use it in GitHub Desktop.
Save stevewithington/5197276 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>
@davidpanzarella
Copy link

Nice one! Simple and clean.

@JonnyHayes
Copy link

SOOOOO COOOOL!!!! Thanks Steve - you've saved me days.

@JonnyHayes
Copy link

… and if you're NOT using bootstrap add < cfset $.loadShadowBoxJS() > in you footer.cfm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment