Custom Search
Contents
28. Custom Search#
28.1. Custom Search in Volto#
Volto has (since Volto 14) a search block that allows you to build custom searches without additional addons.
28.1.1. Exercise#
Show talks on the talks page with a search block. The visitor should see a filter for the type of talk (Keynote, Talk, Lightning Talk).
You can add facets in the sidebar, but "type of talk" is not available. What is necessary to implement?
Remember what we did to show featured content on the front page.
Tips for a Solution
The field "type_of_talk" needs to be indexed in catalog.
"type_of_talk" needs to be a collection criterion
After adding an index and a criterion, and restarting the backend, and re-installing the add-on, the index is present in catalog but empty.
For populating the index you can go to http://localhost:8080/Plone/portal_catalog/manage_catalogIndexes and reindex the new index.
In case you want to change something of the index, the index can be deleted. A re-start of the backend, a re-install of the add-on and a new re-index of the index will populate the index.
Check the entries by switching to "Browse" button.
Solution
catalog.xml
<index name="type_of_talk" meta_type="KeywordIndex">
<indexed_attr value="type_of_talk"/>
</index>
<column value="type_of_talk"/>
querystring.xml
<records interface="plone.app.querystring.interfaces.IQueryField"
prefix="plone.app.querystring.field.type_of_talk">
<value key="title" i18n:translate="">Type of Talk</value>
<value key="enabled">True</value>
<value key="sortable">False</value>
<value key="operations">
<element>plone.app.querystring.operation.selection.any</element>
<element>plone.app.querystring.operation.selection.all</element>
<element>plone.app.querystring.operation.selection.none</element>
</value>
<value key="group" i18n:translate="">Metadata</value>
<value key="vocabulary">ploneconf.types_of_talk</value>
</records>
28.2. Custom Search in Plone Classic#
If the Plone Classic chapters about Views (Views II: A Default View for "Talk") and catalog-searches ((Views III: A Talk List)) seem complex, the custom search add-ons shown below might be a great alternative until you feel comfortable writing views and templates.
Here are two add-ons that allow you to add custom searches and content listings through the web ("TTW", requiring no programming: only the web browser) in Plone.
28.2.2. collective.collectionfilter#
A more lightweight solution for custom searches and faceted navigation is collective.collectionfilter. By default it allows you to search among the results of a collection and/or filter the results by keywords, author or type.
It can also be extended quite easily to allow additional filters (like audience
).