Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mattlevine/feefe490d719d2e53a92afdb306261de to your computer and use it in GitHub Desktop.
Save mattlevine/feefe490d719d2e53a92afdb306261de to your computer and use it in GitHub Desktop.
Mura CMS : Related Content Iterators and outputting extended attributes
<cfoutput>
<cfscript>
// Content Bean of the Section of the site to narrow feed down to
cBean = $.getBean('content').loadBy(title='Blog');
// Feed Bean
fBean = $.getBean('feed');
fBean.addParam(
relationship='and'
, field='tcontent.parentid'
, dataType='varchar'
, criteria=cBean.getContentID()
);
// Iterator
it = fBean.getIterator();
</cfscript>
<cfloop condition="it.hasNext()">
<cfscript>
item = it.next();
itRelated = item.getRelatedContentIterator();
// if you want to narrow down to a specific Related Content Set
//itRelated = item.getRelatedContentIterator(name='The Related Content Set Name Goes Here');
// New in 6.1
//extendedAttributesList = item.getExtendedAttributesList();
// Attributes to output
atts = 'title,summary,someExtendedAttribute';
</cfscript>
<div>
<h3>#item.getTitle()#</h3>
<cfif itRelated.hasNext()>
<ul>
<cfloop condition="itRelated.hasNext()">
<cfset rItem = itRelated.next()>
<li>
<cfloop from="1" to="#ListLen(atts)#" index="i">
<cfset att = ListGetAt(atts, i)>
<cfif Len(att)>
<div>#rItem.getValue(att)#</div>
</cfif>
</cfloop>
</li>
</cfloop>
</ul>
</cfif>
</div>
</cfloop>
</cfoutput>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment