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">
 4
 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>
16
17</registry>

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

  • The prefix refers to the featured index we just created.

  • The operations elements define the provided criterion values to filter the listing.

  • The group value defines the group under which the entry shows up in the selection widget, in our case 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.

25.3. Outlook: block variations

The listing block comes with default variations for the display. The editor can choose from these vaiations to change the template for the listing: with thumbnail image or without, etc.. Your project maybe needs a custom template. The way to go would be to create an additional variation of the listing block. See block variations for more information.