--- a/src/pyams_default_theme/shared/resource/__init__.py Tue Mar 26 16:49:32 2019 +0100
+++ b/src/pyams_default_theme/shared/resource/__init__.py Tue Mar 26 16:50:56 2019 +0100
@@ -15,9 +15,9 @@
from zope.interface import Interface
from pyams_content.shared.resource import IAgeRange, IResourceInfo, IWfResource
-from pyams_default_theme import _
from pyams_default_theme import lightbox
-from pyams_default_theme.features.search.portlet import ISearchResultRenderer, WfSharedContentSearchResultRenderer
+from pyams_default_theme.features.search.portlet import ISearchResultHeader, ISearchResultRenderer, \
+ WfSharedContentSearchResultRenderer
from pyams_default_theme.interfaces import ISearchResultsView
from pyams_default_theme.shared.common.interfaces import ICustomContentSpecificitiesParagraphRenderer, \
ICustomContentSpecificitiesRenderer
@@ -28,6 +28,8 @@
from pyams_utils.text import text_to_html
from pyams_viewlet.viewlet import ViewContentProvider
+from pyams_default_theme import _
+
@adapter_config(context=(IWfResource, IPyAMSUserLayer, Interface),
provides=ICustomContentSpecificitiesRenderer)
@@ -54,14 +56,17 @@
return translate(result).format(value)
+@adapter_config(context=(IWfResource, IPyAMSUserLayer, ISearchResultsView), provides=ISearchResultHeader)
+def resource_search_result_header_adapter(context, request, view):
+ """Resource search result header adapter"""
+ header = II18n(context).query_attribute('header', request=request)
+ if header:
+ return text_to_html(header)
+ else:
+ return ''
+
+
@adapter_config(context=(IWfResource, IPyAMSUserLayer, ISearchResultsView), provides=ISearchResultRenderer)
@template_config(template='templates/search-result.pt', layer=IPyAMSUserLayer)
class WfResourceSearchResultRenderer(WfSharedContentSearchResultRenderer):
"""Resource search result renderer"""
-
- @property
- def header(self):
- header = II18n(self.context).query_attribute('header', request=self.request)
- if header:
- return text_to_html(header)
- return ''
--- a/src/pyams_default_theme/shared/resource/templates/search-result.pt Tue Mar 26 16:49:32 2019 +0100
+++ b/src/pyams_default_theme/shared/resource/templates/search-result.pt Tue Mar 26 16:50:56 2019 +0100
@@ -1,4 +1,4 @@
-<tal:var define="target view.get_url(context)"
+<tal:var define="target view.url"
i18n:domain="pyams_default_theme">
<div class="thumbnail pull-left col-lg-2 col-md-2 col-sm-3 hidden-xs"
tal:define="illustration tales:pyams_illustration(context)"
@@ -14,12 +14,11 @@
</div>
<div>
<a href="${target}">
- <h3>${i18n:context.title}</h3>
+ <h3>${view.title}</h3>
</a>
<div class="tags">${structure:tales:tags(context)}</div>
- <div class="header"
- tal:define="header i18n:context.header">
- ${structure:tales:html(header)}
+ <div class="header">
+ ${structure:tales:html(view.header)}
</div>
</div>
</tal:var>