You will need to customize the search view to set new sorting options, and change the default sorting if no sorting is specified.
If you still need to sort by relevance, use a non-empty value, which you then change in the filter_query method:
from plone.app.search.browser import _, Search, SortOption class MyCustomSearch(Search): def filter_query(self, query): query = super(MyCustomSearch, self).filter_query(query) if 'sort_on' not in query:
Then register this submission on your website; if you use the darkest layer:
<configure xmlns="http://namespaces.zope.org/zope" xmlns:browser="http://namespaces.zope.org/browser" i18n_domain="plone"> <browser:page name="search" layer=".interfaces.IYourCustomThemeLayer" class=".yourmodule.MyCustomSearch" permission="zope2.View" for="*" template="search.pt" /> <browser:page name="updated_search" layer=".interfaces.IYourCustomThemeLayer" class=".yourmodule.MyCustomSearch" permission="zope2.View" for="Products.CMFCore.interfaces.IFolderish" template="updated_search.pt" /> </configure>
You need to copy the search.pt and updated_search.pt templates from the plone.app.search package.
source share