# HG changeset patch # User Thierry Florac # Date 1530621259 -7200 # Node ID 902e9f5dc2962ee24d206ea3e7e4fb8b72476510 # Parent af7c769f195d77e32ca8b2ebc4a6eac689791d66 Updated simple header template diff -r af7c769f195d -r 902e9f5dc296 src/pyams_default_theme/features/header/skin/__init__.py --- a/src/pyams_default_theme/features/header/skin/__init__.py Tue Jul 03 14:33:51 2018 +0200 +++ b/src/pyams_default_theme/features/header/skin/__init__.py Tue Jul 03 14:34:19 2018 +0200 @@ -17,6 +17,7 @@ # import interfaces from pyams_content.component.association.interfaces import IAssociationInfo +from pyams_content.component.links.interfaces import IInternalLink from pyams_content.features.header.interfaces import IHeaderTarget, IHeaderRenderer, IHeaderSettings, \ IHeaderRendererSettings from pyams_default_theme.features.header.interfaces import ISimpleHeaderRendererSettings @@ -27,6 +28,7 @@ from pyams_default_theme.features.header import SimpleHeaderRendererSettings from pyams_template.template import template_config from pyams_utils.adapter import adapter_config +from pyramid.location import lineage from pyams_default_theme import _ @@ -51,10 +53,21 @@ settings_key = 'PyAMS::simple' settings_interface = ISimpleHeaderRendererSettings + def update(self): + super(SimpleHeaderRenderer, self).update() + self.request.annotations['REQUEST_PATH'] = list(lineage(self.request.context)) + @staticmethod def get_link_info(link): return IAssociationInfo(link) + def is_active(self, link): + if IInternalLink.providedBy(link): + target = link.get_target() + if target is not None: + return target in self.request.annotations['REQUEST_PATH'] + return False + @adapter_config(context=SimpleHeaderRenderer, provides=IHeaderRendererSettings) def simple_header_renderer_settings_factory(context): diff -r af7c769f195d -r 902e9f5dc296 src/pyams_default_theme/features/header/skin/templates/simple-header.pt --- a/src/pyams_default_theme/features/header/skin/templates/simple-header.pt Tue Jul 03 14:33:51 2018 +0200 +++ b/src/pyams_default_theme/features/header/skin/templates/simple-header.pt Tue Jul 03 14:34:19 2018 +0200 @@ -9,16 +9,23 @@ - + + + - - Link
-
+