Documentation Center

Using filters to assemble content dynamically

You can add Component Presentations statically to a Page in which case the resulting Web page always shows the same Component Presentations, or you can determine which Component Presentations to display on the Page based on dynamic criteria using a filter to assemble content dynamically.

About this task

For example, you may want to display the five most recently published Component Presentations, or all Component Presentations that have been marked 'sports'. To do this, specify a query consisting of content criteria and then include (some or all) Components that meet those criteria.

Procedure

  1. Decide what type of filter you want to make, for example:
    Related Items filter
    select Component Presentations based on one or more Keywords.
    Most Visited Components filter
    select Component Presentations based on the number of times they were accessed (this requires implementation of Tracking, see Profiling and personalization).
    Most Recently Published Components filter
    select Component Presentations based on their Initial Publication Date.
  2. If the type of information you are filtering on is not included in the standard metadata of a Component, create custom metadata (for example, Categories and Keywords) for this information.
  3. Publish the Component Presentations you want to filter on as Dynamic Component Presentations.
  4. Create a Page Template that uses the Query class to create and execute a query using the executeQuery or ExecuteQuery method.
    The query returns an array of Component URIs. Combine these Components with a Component Template of your choice to produce the Component Presentations you want to show.
  5. You can configure the results of the query in the following ways:
    • You can restrict the number of Components to a specific number.
    • You can sort the result on a specific metadata field.
    • You can specify a sort direction (ascending/descending).
  6. Create a Page without adding any Component Presentations to it, and associate it with the Page Template you just created.
  7. Publish this Page and examine the result on the Web site.