--- a/src/pyams_content/features/search/portlet/__init__.py Tue Jan 08 16:15:45 2019 +0100
+++ b/src/pyams_content/features/search/portlet/__init__.py Wed Jan 09 12:15:30 2019 +0100
@@ -40,6 +40,11 @@
force_canonical_url = FieldProperty(ISearchResultsPortletSettings['force_canonical_url'])
@staticmethod
+ def has_user_query(request):
+ params = request.params
+ return params.get('user_search', '').strip() or params.get('tag', '').strip()
+
+ @staticmethod
def _get_items(request=None, limit=None, ignore_cache=False):
context = get_parent(request.context, ISearchFolder)
if context is None:
@@ -59,7 +64,7 @@
request=request)
def get_items(self, request=None, limit=None, ignore_cache=False):
- if not (self.allow_empty_query or request.params.get('user_search', '').strip()):
+ if not (self.allow_empty_query or self.has_user_query(request)):
yield from iter(((), 0),)
else:
check, items = tee(SearchResultsPortletSettings._get_items(request, limit, ignore_cache))
--- a/src/pyams_content/features/search/portlet/interfaces.py Tue Jan 08 16:15:45 2019 +0100
+++ b/src/pyams_content/features/search/portlet/interfaces.py Wed Jan 09 12:15:30 2019 +0100
@@ -14,11 +14,10 @@
from zope.schema import Bool
+from pyams_content import _
from pyams_i18n.schema import I18nTextLineField
from pyams_portal.interfaces import IPortletSettings
-from pyams_content import _
-
class ISearchResultsPortletSettings(IPortletSettings):
"""Search results portlet settings"""
@@ -33,6 +32,9 @@
required=True,
default=True)
+ def has_user_query(self):
+ """Check if user entered custom search arguments"""
+
force_canonical_url = Bool(title=_("Force canonical URL?"),
description=_("By default, internal links use a \"relative\" URL, which tries to "
"display link target in the current context; by using a canonical URL, "