Multiple teasers on one page, but without any duplicates

Crownpeak employee
Crownpeak employee
0 0 431

teaser1.pngA common request is to display several teasers on a page wihout any duplicates. How do I implement this? Use a global variable in the page context to store the already shown articles.

This page has 3 sections, each section can show several teasers for other articles. We only want to list teaser articles with a publish date greater than the specified date.


The section template:


<CMS_FUNCTION name="contentSelect" resultname="fr_article">
<CMS_PARAM  name="schema" value="knowledgebase" />
<CMS_VALUE_PARAM  name="from" value="publishdate" />
<QUERY entityType="article">
     <FILTERPARAM parameter="from" datatype="java.util.Date" value="1143758280000" />
     <GT attribute="publishdate" datatype="java.util.Date" parameter="from"/>
$-- Get the article list from the page context --$
$CMS_SET(listedArticles, #global.pageContext.getVariableValue("listedArticles"))$
$CMS_SET(count, 0)$
$CMS_FOR(article, fr_article)$
   $CMS_IF(count <= maxcount -1 && !listedArticles.contains($
     $-- add given article to the list --$
     $CMS_SET(void, listedArticles.add($
     $CMS_SET(count, count + 1)$
$-- Write article list back in the page context --$
$CMS_SET(void,#global.pageContext.setVariableValue("listedArticles" , listedArticles))$
Version history
Last update:
‎07-01-2010 10:40 AM
Updated by: