For Developers

Simple collector with detail page

This example demonstrates the implementation, configuration and usage of a simple collector to display resources of a specified folder in a list.

In OpenCms resources are typically searched using Solr. Since Apache Solr is integrated into OpenCms the most common way to get a list of resources is to use the JSP-Taglib:

<%-- Collect the resources --%>
<cms:contentload collector="byContext" param="${solrQuery}" preload="true">

Using the collector "byContext" allows you to search in the Solr index by passing a query in the Solr query syntax:

?fq=type:ddarticle&sort=lastmodified desc

Optionally you're able to append a create path (separated by a pipe symbol) like:

|createPath=/dev-demo/collector-with-detail-page/.content/articles

This tells OpenCms where to create new resources when the "+"-Symbol of the first listed resource is used.

A code snippet could look like

<%-- Define a Solr query --%>
<c:set var="solrQuery">?fq=type:ddarticle&sort=lastmodified desc</c:set>

<%-- Define a create path --%>
<c:set var="createPath">/dev-demo/collector-with-detail-page/.content/articles/</c:set>

<%-- Collect the resources --%>
<cms:contentload collector="byContext" param="${solrQuery}|createPath=&{createPath}" preload="true" >

Dev-Demo: Simple Solr collector

Article 2

The text of the article 2.

Article 3

The text of the article 3.

Article 4

This is text of the article 4.