This example describes how a collection filter limits the contents in a slot using a scenario. Consider a Web site that provides articles about various topics. To ensure that only current articles are displayed to users, each article has a start and end date property. Articles that are active on the current day are added to a slot.

The scenario begins with an event that adds all NewsRepositoryItems to the Articles slot. The next action, Filter Slot Contents, passes the items in Articles to StartEndDateFilter. To learn more about this action, see Filter Slot Contents Action.

Rather than use a scenario to filter a slot, you can use a JSP to access a filled slot and filter the contents within it. The StartEndDateFilterDroplet accesses the StartEndDateFilter component, which performs the filtering task and adds the resultant collection to the Articles slot:

<dspel:droplet name="/atg/collections/filter/droplet/StartEndDateDroplet">
   <dspel:param name="collection" beanvalue="Articles"/>
   <dspel:param name="collectionIdentifierKey" value="date"/>

   <dspel:oparam name="output">
      Featured Articles:<p>
      <dsp:droplet name="/atg/targeting/TargetingForEach">
         <dsp:param bean="/atg/registry/Slots/Articles" name="targeter"/>
         <dsp:oparam name="output">
            <dspel:valueof param="filteredCollection"/>

   <dsp:oparam name="empty">
      There are no articles today.

Each article has a start and end date, which StartEndDateFilter compares to the current date. All articles that are “started” and have not yet “ended” remain in the slot. All others are removed by the filter from the slot.

loading table of contents...