Collection Function

The collection function is used to display the list of links that were created as a collection in the Ektron CMS400.NET Workarea. The ecmCollection function is highly customizable, allowing you to easily define how the collection data will be displayed on the Web page.

Shown here is the format of the ecmCollection function.

<CFMODULE template="#request.ecm.AppPath#ecmCollection.cfm"

id="2"

displayFunction="ecmTeaser"

>

This function is basically the same as the Collection function in ASP. See Collection Function for details.

The only difference between the Coldfusion function and the ASP one is the syntax for implementing it. The ColdFusion example is below.

Example Using the ecmNavigation Display Function

The following is an example of a collection function being used as a navigation menu in the Ektron CMS400.NET sample Web site.

<CFMODULE id="1" displayFunction="ecmNavigation"

template="#request.ecm.AppPath#ecmCollection.cfm">

As stated earlier, the format of the collection on the Web page depends on the displayFunction that is used. Below is the source code for the display function “ecmNavigation”.

<cfparam name="Attributes.nId" default="">

<cfparam name="Attributes.href" default="">

<cfparam name="Attributes.target" default="">

<cfparam name="Attributes.startStyle" default="">

<cfparam name="Attributes.endStyle" default="">

<cfset LocalError = "">

<cfobject class="Ektron CMS400.NETContentBrv2.Ektron CMS400.NETContent" Action="Create" name="cmsObj">

<cfset cNavs = cmsObj.GetEcmCollectionItems(request.ecm.AppConfStr,Attributes.nId,0,request.ecm.cmsPreview,request.ecm.user_id,request.ecm.site_id,LocalError)>

<cfif cNavs.Count()>

<cfset nString = "">

<cfloop collection=#cNavs# Item=nav>

<cfset nString = nString & "<a href=""">

<cfif len(Attributes.href)>

<cfif FindNoCase("?", Attributes.hrefs)>

<cfset nString = nString & Attributes.href & "&id=" &

nav.Item("ContentID")>

<cfelse>

<cfset nString = nString & Attributes.href & "?id=" &

nav.Item("ContentID")>

</cfif>

<cfelse>

<cfset nString = nString & nav.Item("ContentLinks")>

</cfif>

<cfset nString = nString & """ ">

<cfif len(Attributes.target)>

<cfset nString = nString & "target=""" & Attributes.target & """ ">

</cfif>

<cfset nString = nString & ">">

<cfif len(Attributes.startStyle)>

<cfset nString = nString & Attributes.startStyle>

</cfif>

<cfset nString = nString & nav.Item("ContentTitle")>

<cfif len(Attributes.endStyle)>

<cfset nString = nString & Attributes.endStyle>

</cfif>

<cfset nString = nString & "</a>">

</CFLOOP>

<cfmodule str="#nString#" nId="#Attributes.nId#" template="#request.ecm.AppPath#ecmshowCollectionsContent.cfm">

</cfif>

<cfset nNavs = "Nothing">

<cfset cmsObj = "Nothing">

As you can see, the ecmNavigation function is a simple ASP function that creates a table of the links that belong to the collection specified. The function also displays the title of the content blocks by using the “info(“ContentTitle”)) building block.

Example Using the ecmTeaser Display Function

The following is an example of a collection function being used as a navigation menu in the Ektron CMS400.NET sample Web site.

<CFMODULE id="2" displayFunction="ecmTeaser"

template="#request.ecm.AppPath#ecmCollection.cfm">

In this example, the collection with an ID=2 is displayed, and the function “ecmTeaser” defines how to display the collection data on a Web page. Here is how the collection would appear on a Web page.

As stated earlier, the format of the collection on the Web page depends on the displayFunction that is used. Below is the source code for the display function “ecmTeaser”.

<cfparam name="Attributes.nID" default="">

<cfparam name="Attributes.href" default="">

<cfparam name="Attributes.ShowSummary" default="">

<cfparam name="Attributes.StyleInfo" default="">

<cfparam name="Attributes.target" default="">

<cfset ErrorString = "">

<cfobject class="Ektron CMS400.NETContentBrv2.Ektron CMS400.NETContent" Action="Create" name="tObj">

<cfset cTeasers = tObj.GetEcmCollectionItems(request.ecm.AppConfStr, Attributes.nId, 0, request.ecm.cmsPreview, request.ecm.user_id, request.ecm.site_id, ErrorString)>

<cfset tString = "<table border=""0"" cellspacing=""0"" cellpadding=""0"" width=""100%"">">

<cfif cTeasers.Count()>

<cfloop collection=#cTeasers# Item=cT>

<cfset tString = tString & "<tr><td>">

<cfset tString = tString & "<a href=""">

<cfif len(Attributes.href)>

<cfif FindNoCase("?", Attributes.hrefs)>

<cfset tString = tString & Attributes.href & "&id=" &

cT.Item("ContentID")>

<cfelse>

<cfset tStringi = tString & Attributes.href & "?id=" &

cT.Item("ContentID")>

</cfif>

<cfelse>

<cfset tString = tString & cT.Item("ContentLinks")>

</cfif>

<cfset tString = tString & """ ">

<cfif len(Attributes.target)>

<cfset tString = tString & "target=""" & Attributes.target & """ ">

</cfif>

<cfset tString = tString & ">">

<cfset tString = tString & cT.Item("ContentTitle") & "</a>" & "&nbsp;(" &

DateFormat(cT.Item("DateModified"), "mm/dd/yyyy") & " " &

TimeFormat(cT.Item("DateModified"), "h:mm:ss tt") & ")</td></tr><tr><td>" &

cT.Item("ContentTeaser")>

<cfset tString = tString & "</td></tr><tr><td>&nbsp;</td></tr>">

</cfloop>

<cfset tString = tString & "</table>">

<cfmodule str="#tString#" nId="#Attributes.nId#" template="#request.ecm.AppPath#ecmshowCollectionsContent.cfm">

</cfif>

As you can see, the ecmTeaser function is a simple ASP function that creates a table of the links that belong to the collection specified.

The ecmTeaser function also displays the:

Content Title

Date Modified

Content Teaser

Collection Variables

See Collection Attributes

Display Function

The display function defines how collection data appears on a Web page. Using ColdFusion scripting, you can create your own display functions, or use the three included functions.

Previous TopicNext Topic|