Last active
January 18, 2017 16:44
-
-
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.
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
<!--- | |
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> |
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
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