Skip to content

Instantly share code, notes, and snippets.

@stevewithington
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stevewithington/9009257 to your computer and use it in GitHub Desktop.
Save stevewithington/9009257 to your computer and use it in GitHub Desktop.
Mura CMS : If a Mura 'component' exists, then the object will be returned, otherwise an empty string will be returned.
<cfscript>
// drop this in your Theme or Site contentRenderer.cfc
public any function dspComponent(string componentid, siteid=variables.$.siteConfig('siteid')) {
var bean = IsValid('uuid', arguments.componentid
? variables.$.getBean('content').loadBy(contentid=arguments.componentid, siteid=arguments.siteid)
: variables.$.getBean('content').loadBy(title=arguments.componentid, type='Component', siteid=arguments.siteid);
return !bean.getIsNew()
? variables.$.dspObject(object='component', objectid=bean.getContentID(), siteid=arguments.siteid)
: '';
}
</cfscript>
<!--- Usage --->
<cfoutput>
#$.dspComponent('Some Component Name or ID goes here')#
</cfoutput>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment