Showing Related Content


One of FarCry's real strengths is the ability to easily create and display cross related content. All you need is a content type that records the references using an array or library property (for example, dmHTML the content type for standard HTML pages) and some presentation logic in your view.

Assuming you are working with dmHTML for now, most people get stuck on how they might output related link information in their webskin displays.

A custom tag specifically for building related content has been added to the code base: skin:RelatedContent

Code Snippet

In FarCry 4.0 you can get extended information about your array property using the bArrayAsStructs parameter. In the extended array you will find the typename property for your related content. We use this to correctly invoke the right content type without having to look up the typename.

<!--- only bother if there is related content --->
<cfif arrayLen(stobj.arelatedids)>
  <!--- grab an array of extended data structs for processing --->
  <cfset aExtended=getData(objectid=stobj.objectid, bArraysAsStructs=true) />
  <cfloop from="1" to="#arrayLen(aExtended)#" index="i">
    <!--- create an instance of the relevant type based on typename --->
    <cfset oType=createobject("component", application.types[aExtended[i].typename]) />
    <!--- render a specific view for the content item, perhaps a teaser --->
    <cfset HTML=oType.getView(objectid=aExtended[i].objectid, template="displayTeaser") />