Last active
May 5, 2016 21:08
-
-
Save bradmarshall/a54dc2ba10a790dd5249d89873047d3c to your computer and use it in GitHub Desktop.
In Mura CMS, I needed to create a folder listing that contained items from two separate folders, each of which are on their own site. If the folders were on one site you could achieve this with a single feed easily but on two different sites it gets trickier. My solution was to create two separate feeds, extract the query result from both and ja…
This file contains hidden or 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> | |
// Get main site's feed. | |
variables.feed = $.getBean("feed"); | |
variables.feed.setSiteID("default"); | |
variables.feed.setMaxItems(0); | |
variables.feed.setSortBy(esapiEncode('html_attr',variables.$.event('sortby'))); | |
variables.feed.setSortDirection(esapiEncode('html_attr',variables.$.event('sortdirection'))); | |
variables.feed.setContentID("57A975C9-155D-11DA-00EE3AC56A450048"); | |
variables.qryMainSite = variables.feed.getQuery(); | |
// Get current folder's feed. | |
variables.feed = $.getBean("feed"); | |
variables.feed.setSiteID(variables.$.event('siteid')); | |
variables.feed.setMaxItems(0); | |
variables.feed.setSortBy(esapiEncode('html_attr',variables.$.event('sortby'))); | |
variables.feed.setSortDirection(esapiEncode('html_attr',variables.$.event('sortdirection'))); | |
variables.feed.setContentID(esapiEncode('html_attr',variables.$.content('contentid'))); | |
variables.qryCurrentSite = variables.feed.getQuery(); | |
// Combine feeds via Query of Queries. | |
variables.queryService = new query(); | |
variables.queryService.setName("myQuery"); | |
variables.queryService.setDBType("query"); | |
variables.queryService.setAttributes(mainQuery=variables.qryMainSite, departmentQuery=variables.qryCurrentSite); | |
variables.objQueryResult = variables.queryService.execute(sql="SELECT * | |
FROM mainQuery | |
UNION | |
SELECT * | |
FROM departmentQuery | |
ORDER BY releaseDate DESC"); // most recent to least recent. | |
variables.qryCombined = variables.objQueryResult.getResult(); | |
// Pull an iterator from our combined query object. | |
variables.iterator = variables.getBean("contentIterator"); | |
variables.iterator.setQuery(variables.qryCombined); | |
</cfscript> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment