Last active
August 29, 2015 13:56
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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