Added property to header renderer to get main navigation element class
authorThierry Florac <tflorac@ulthar.net>
Mon, 07 Sep 2020 16:32:20 +0200
changeset 520 5bfb61ee72a8
parent 519 d3f9766fd25d
child 521 f86cf0f11634
Added property to header renderer to get main navigation element class
src/pyams_default_theme/features/header/skin/__init__.py
src/pyams_default_theme/features/header/skin/interfaces.py
src/pyams_default_theme/features/header/skin/templates/simple-header.pt
--- a/src/pyams_default_theme/features/header/skin/__init__.py	Mon Jul 20 14:19:25 2020 +0200
+++ b/src/pyams_default_theme/features/header/skin/__init__.py	Mon Sep 07 16:32:20 2020 +0200
@@ -10,8 +10,6 @@
 # FOR A PARTICULAR PURPOSE.
 #
 
-__docformat__ = 'restructuredtext'
-
 import logging
 
 from pyramid.decorator import reify
@@ -20,14 +18,13 @@
 
 from pyams_cache.beaker import get_cache
 from pyams_content.component.association.interfaces import IAssociationInfo
-from pyams_content.features.header.interfaces import IHeaderRenderer, IHeaderRendererSettings, IHeaderSettings, \
-    IHeaderTarget
+from pyams_content.features.header.interfaces import IHeaderRenderer, IHeaderRendererSettings, \
+    IHeaderSettings, IHeaderTarget
 from pyams_content.features.renderer.interfaces import HIDDEN_RENDERER_NAME
 from pyams_content.root import ISiteRoot
-from pyams_default_theme import _
 from pyams_default_theme.features.header import SimpleHeaderRendererSettings
 from pyams_default_theme.features.header.interfaces import ISimpleHeaderRendererSettings
-from pyams_default_theme.features.header.skin.interfaces import IHeaderClass
+from pyams_default_theme.features.header.skin.interfaces import IHeaderClass, INavigationClass
 from pyams_default_theme.features.renderer import BaseContentRenderer
 from pyams_portal.interfaces import PREVIEW_MODE
 from pyams_portal.portlet import PORTLETS_CACHE_KEY, PORTLETS_CACHE_NAME, PORTLETS_CACHE_REGION
@@ -40,6 +37,11 @@
 from pyams_utils.traversing import get_parent
 
 
+__docformat__ = 'restructuredtext'
+
+from pyams_default_theme import _
+
+
 logger = logging.getLogger('PyAMS (content)')
 
 
@@ -81,7 +83,14 @@
     @property
     def main_header_class(self):
         request = self.request
-        return request.registry.queryMultiAdapter((request.context, request), IHeaderClass, default='')
+        return request.registry.queryMultiAdapter((request.context, request), IHeaderClass,
+                                                  default='')
+
+    @property
+    def main_navigation_class(self):
+        request = self.request
+        return request.registry.queryMultiAdapter((request.context, request), INavigationClass,
+                                                  default='')
 
     @property
     def search_target(self):
--- a/src/pyams_default_theme/features/header/skin/interfaces.py	Mon Jul 20 14:19:25 2020 +0200
+++ b/src/pyams_default_theme/features/header/skin/interfaces.py	Mon Sep 07 16:32:20 2020 +0200
@@ -17,3 +17,7 @@
 
 class IHeaderClass(Interface):
     """Custom header CSS class"""
+
+
+class INavigationClass(Interface):
+    """Custom navigation CSS class"""
--- a/src/pyams_default_theme/features/header/skin/templates/simple-header.pt	Mon Jul 20 14:19:25 2020 +0200
+++ b/src/pyams_default_theme/features/header/skin/templates/simple-header.pt	Mon Sep 07 16:32:20 2020 +0200
@@ -1,9 +1,9 @@
-<div class="header header-simple"
+<div class="header header-simple ${view.main_header_class}"
 	 tal:define="settings view.settings;
 				 config tales:configuration(request.root);"
 	 tal:condition="settings is not None" i18n:domain="pyams_default_theme">
 	<tal:var replace="structure provider:pyams.banner" />
-	<nav class="navbar"
+	<nav class="navbar ${view.main_navigation_class}"
 		 data-spy="affix" data-offset-top="150">
 		<div class="container">
 			<div class="navbar-header">