25. Creating a dynamic frontpage with Volto blocks

In this part you will:

  • Use a listing block to show content marked as featured

  • Configure additional criterion for listing block

25.1. Add Index as collection criteria

To understand why we need a collection criteria for a dynamic frontpage in Volto and what a collection criterion is, we have to look at the listing block of Volto.

Listing Block sidebar

In the sidebar we see the criteria selection and if we click there, it’ll show some of the choosable criterias ordered in categories like the following:

  • Metadata contains indexes that are counting as metadata like Type (means Portal Types) and Review State

  • Text contains indexes that are counting as text-data like Description and Searchable Text

  • Dates contains indexes which are working with date-data like Effective Date and Creation Date

To get all talks we marked as featured we have to get the listing block to recognize our newly created index. This means we have to add our index to the collection criterias, so we can choose it.

To add our new index as a criterion to be appliable in a listing block or a collection, we have to switch to our backend. There we have to create a plone.app.registry record for our index. This can be achieved by adding a new file profiles/default/registry/querystring.xml:

 1<?xml version="1.0"?>
 2<registry xmlns:i18n="http://xml.zope.org/namespaces/i18n"
 3          i18n:domain="plone">
 5  <records interface="plone.app.querystring.interfaces.IQueryField"
 6           prefix="plone.app.querystring.field.featured">
 7      <value key="title" i18n:translate="">Featured</value>
 8      <value key="enabled">True</value>
 9      <value key="sortable">False</value>
10      <value key="operations">
11          <element>plone.app.querystring.operation.boolean.isTrue</element>
12          <element>plone.app.querystring.operation.boolean.isFalse</element>
13      </value>
14     <value key="group" i18n:translate="">Metadata</value>
15  </records>

To understand this code-snippet, we have to know the information and tags we are using:

  • The title-value refers to the custom index, in our case the featured-index we just created

  • the operations-value is used to filter the items for example isTrue and isFalse for a boolean field like ours

  • the group-value defines under which group the entry shows up in the selection widget, what in our case should be metadata

Like explained in the last chapter we can now restart the instance and import the newly added profile by using the portal_setup in our ZMI.