Skip to content

Instantly share code, notes, and snippets.

@howellcc
Last active January 18, 2017 16:44
Show Gist options
  • Save howellcc/80c814542aa765baead0 to your computer and use it in GitHub Desktop.
Save howellcc/80c814542aa765baead0 to your computer and use it in GitHub Desktop.
MuraCMS: dspPluginDisplayObject: Function will return content of a plugin display object by name.
<!---
Add this function to contentRender.cfc - appReload required.
Then reference by using the following:
#$.getContentRenderer().dspPluginDisplayObject('{plugin title}', '{display Object Name}')#
--->
<cffunction name="dspPluginDisplayObject" >
<cfargument name="pluginTitle" type="string" required="true"/>
<cfargument name="displayObjectName" type="string" required="true" />
<cfset var l = {} />
<cfset l.qryDisplayObjects = application.pluginManager.getDisplayObjectsBySiteID(siteID=$.event('siteID')) />
<cfquery name="l.DisplayObject" dbtype="query">
SELECT objectID
FROM l.qryDisplayObjects
WHERE title = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.pluginTitle#" />
AND name = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.displayObjectName#" />
</cfquery>
<cfif l.DisplayObject.recordCount eq 1>
<cfreturn $.dspObject(object="plugin",objectID=l.DisplayObject.objectID) />
</cfif>
<cfreturn "" />
</cffunction>
public string function dspPluginDisplayObject(required string pluginTitle, required string displayObjectName){
var qryDisplayObjects = application.pluginManager.getDisplayObjectsBySiteID(siteID=$.event('siteID'));
var displayObject = queryExecute(
"SELECT objectID
FROM qryDisplayObjects
WHERE title = :title
AND name = :name",
{
title={cfsqltype:"varchar", value:pluginTitle},
name={cfsqltype:"varchar", value:displayObjectName}
},
{dbType:"query"});
if(displayObject.recordCount eq 1)
return $.dspObject(object="plugin",objectID=displayObject.objectID);
return "";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment