--- a/src/pyams_default_theme/interfaces.py Wed Sep 04 16:06:52 2019 +0200
+++ b/src/pyams_default_theme/interfaces.py Wed Sep 04 16:07:32 2019 +0200
@@ -15,6 +15,10 @@
from zope.interface import Interface, Attribute
+class IContentTitle(Interface):
+ """Content title"""
+
+
class IContentNavigationTitle(Interface):
"""Content navigation title"""
--- a/src/pyams_default_theme/shared/common/__init__.py Wed Sep 04 16:06:52 2019 +0200
+++ b/src/pyams_default_theme/shared/common/__init__.py Wed Sep 04 16:07:32 2019 +0200
@@ -10,12 +10,11 @@
# FOR A PARTICULAR PURPOSE.
#
-__docformat__ = 'restructuredtext'
-
from zope.interface import Interface
+from pyams_content.interfaces import IBaseContent
from pyams_content.shared.common.interfaces import IWfSharedContent
-from pyams_default_theme.interfaces import IContentDate, IContentTag
+from pyams_default_theme.interfaces import IContentDate, IContentTag, IContentTitle
from pyams_i18n.interfaces import II18n
from pyams_skin.interfaces.metas import IHTMLContentMetas
from pyams_skin.layer import IPyAMSUserLayer
@@ -26,7 +25,11 @@
from pyams_workflow.interfaces import IWorkflowPublicationInfo
-@adapter_config(name='title', context=(IWfSharedContent, IPyAMSUserLayer, Interface), provides=IHTMLContentMetas)
+__docformat__ = 'restructuredtext'
+
+
+@adapter_config(name='title', context=(IWfSharedContent, IPyAMSUserLayer, Interface),
+ provides=IHTMLContentMetas)
class SharedContentTitleMetasAdapter(ContextRequestViewAdapter):
"""Title metas adapter"""
@@ -43,6 +46,12 @@
yield ContentMeta('description', description)
+@adapter_config(context=(IBaseContent, IPyAMSUserLayer), provides=IContentTitle)
+def base_content_title_adapter(context, request):
+ """Base content title adapter"""
+ return II18n(context).query_attribute('title', request=request)
+
+
@adapter_config(context=(IWfSharedContent, IPyAMSUserLayer), provides=IContentTag)
def shared_content_tag_adapter(context, request):
"""Default shared content tag adapter"""
--- a/src/pyams_default_theme/shared/common/portlet/templates/head.pt Wed Sep 04 16:06:52 2019 +0200
+++ b/src/pyams_default_theme/shared/common/portlet/templates/head.pt Wed Sep 04 16:07:32 2019 +0200
@@ -4,7 +4,9 @@
</tal:if>
<div class="page-header"
tal:condition="settings.display_header">
- <h1 tal:condition="settings.display_title">${i18n:context.title}</h1>
+ <h1 tal:condition="settings.display_title">
+ ${structure:provider:pyams_content.title}
+ </h1>
<div class="small">
<tal:var define="header tales:i18n(context, 'header', '')">${structure:tales:html(header)}</tal:var>
</div>
--- a/src/pyams_default_theme/shared/common/portlet/templates/title.pt Wed Sep 04 16:06:52 2019 +0200
+++ b/src/pyams_default_theme/shared/common/portlet/templates/title.pt Wed Sep 04 16:07:32 2019 +0200
@@ -0,0 +1,1 @@
+${view.title}
\ No newline at end of file
--- a/src/pyams_default_theme/shared/common/portlet/title.py Wed Sep 04 16:06:52 2019 +0200
+++ b/src/pyams_default_theme/shared/common/portlet/title.py Wed Sep 04 16:07:32 2019 +0200
@@ -10,20 +10,33 @@
# FOR A PARTICULAR PURPOSE.
#
-__docformat__ = 'restructuredtext'
-
from zope.interface import Interface
from pyams_content.shared.common.portlet.interfaces import ISharedContentTitlePortletSettings
+from pyams_default_theme.interfaces import IContentTitle
from pyams_portal.interfaces import IPortalContext, IPortletRenderer
from pyams_portal.portlet import PortletRenderer
-from pyams_skin.layer import IPyAMSLayer
+from pyams_skin.layer import IPyAMSLayer, IPyAMSUserLayer
from pyams_template.template import template_config
from pyams_utils.adapter import adapter_config
+from pyams_viewlet.viewlet import contentprovider_config, ViewContentProvider
+
+
+__docformat__ = 'restructuredtext'
from pyams_default_theme import _
+@contentprovider_config(name='pyams_content.title', layer=IPyAMSUserLayer, view=Interface)
+@template_config(template='templates/title.pt', )
+class SharedContentTitleProvider(ViewContentProvider):
+ """Shared content title viewlet"""
+
+ @property
+ def title(self):
+ return self.request.registry.queryMultiAdapter((self.context, self.request), IContentTitle)
+
+
@adapter_config(context=(IPortalContext, IPyAMSLayer, Interface, ISharedContentTitlePortletSettings),
provides=IPortletRenderer)
@template_config(template='templates/title.pt', layer=IPyAMSLayer)
@@ -31,3 +44,7 @@
"""Shared content title portlet renderer"""
label = _("Default title renderer")
+
+ @property
+ def title(self):
+ return self.request.registry.queryMultiAdapter((self.context, self.request), IContentTitle)