Lists with the integrated list type
Since version 11, OpenCms ships with an integrated list type that supports the collection of list entries via Solr and features:
- Full text search
- Sorting by title, date or order
- Blacklisting of contents
- Various time range constraints
- Pagination, even with different page sizes
- Filter facets for categories
- Filter facet for folders
- Range facet for time ranges (year and month, as useful for archives)
Lists of that type even have a dedicated workplace app for managing the list.
The integrated list is designed to ease list creation. OpenCms 10 introduced the
<cms:search> tag and propagated it's use for building lists. Since for most use cases the tag is far too powerful and hence unnecessarily complicated to configure, the integrated list type with all its related features (e.g., a new tag
<cms:simplesearch>) is the easy to configure way of building lists that are sufficient for most use cases.
Using the integrated list, all you need to do is writing a formatter for it.
This topic explains the integrated list type and directs you to other topics that describe features that are relevant for building lists as well.
The list type and its app
OpenCms 11 ships with an integrated list content type. It allows you to easily build lists of content and is intended to configure what contents should be displayed in the list very easily. In essence, the content is a simplified configuration for a Solr search query for the contents to display. Additionally, it holds the information on the formatting for the displayed list entries.
The integrated list content features a specific workplace app where you can see the contents displayed in the list and also the filter options you have on the contents.
All information on the list management app is found here.
Using the list in your template
To use the list in your template you have to:
- Configure the list type (
listconfig) in your (sub-)sitemap or in one module in your system
- Write a formatter for type
listconfigthat allows you to drop the list to your pages.
Configuration in the sitemap or module
You can configure the list type to be present globally in your system by configuring in a module, typically the module you provide list formatters with. Or, you can configure it in the sitemap configuration of your site or subsite. Therefor, open the sitemap configuration, e.g., from the sitemap editor by chosing "Advanced -> Sitemap configuration" in the context menu. An example configuration for the list is shown below. Necessary is only to put the "Type name" "listconfig", the other settings are optional.
Writing a formatter for lists
OpenCms does not provide a formatter for the list contents by default. The formatter is very specific for your template, hence there's no point in providing a default one. In essence, you feed the list content into the
<cms:simplesearch> tag and then you get the collected contents (and some extra information) as result.
The attribute exposed by
<cms:simplesearch> is the same as exposed by
<cms:search>. Here, we provide a fully featured demo formatter for dealing with the result.