Skip to content

Instantly share code, notes, and snippets.

@stevewithington
Last active January 3, 2016 22:19
Show Gist options
  • Save stevewithington/8527722 to your computer and use it in GitHub Desktop.
Save stevewithington/8527722 to your computer and use it in GitHub Desktop.
Mura CMS : Example of how to obtain a recordset/query result of child content item's tags and their counts. As well as an example of how to filter a dynamic feed based on a specific tag.
<cfscript>
rsChildTags = $.getBean('contentGateway').getTagCloud(
siteid = $.event('siteid')
, parentid = $.content('contentid')
, categoryid = $.event('categoryid')
, taggroup = '' // could narrow down to a specific tag group as of 6.1
);
WriteDump(var=rsChildTags, label='rsChildTags');
// This is taken from another example of how to search/filter content in Mura CMS: https://gist.github.com/stevewithington/3866582
feed = $.getBean('feed');
if ( Len($.event('tag')) ) {
feed.addParam(
relationship='AND'
,field='tcontenttags.tag'
,dataType='varchar'
,criteria=URLDecode($.event('tag'))
);
}
it = feed.getIterator();
</cfscript>
<cfoutput>
<cfif it.hasNext()>
<ul>
<cfloop condition="it.hasNext()">
<cfset item = it.next() />
<li>
<h3 class="feed-title">
<a href="#item.getURL()#">#item.getValue('title')#</a>
</h3>
<cfif len(item.getTags())>
<div class="tags wrapper">
<h4>Tags</h4>
<cfloop from="1" to="#ListLen(item.getTags())#" index="t">
<a href="#$.content().getURL(queryString='tag=#URLEncodedFormat(trim(ListGetAt(item.getTags(),t)))#')#"<cfif trim($.event('tag')) eq trim(ListGetAt(item.getTags(), t))> class="current"</cfif>>#HTMLEditFormat(trim(ListGetAt(item.getTags(), t)))#</a><cfif t neq ListLen(item.getTags())>, </cfif>
</cfloop>
</div>
</cfif>
</li>
</cfloop>
</ul>
<cfelse>
<div class="alert alert-info">
<strong>Sorry!</strong> No content items match your filter criteria.
</div>
</cfif>
</cfoutput>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment