Thanks to everyone for the whole answer to my question. Unfortunately, the solution you all provided does not work for me. Therefore, I myself did this to hide the navigation portlet when logging out.
Step 1: In overrides.zcml
<plone:portlet name="navigation_bar" interface="plone.app.portlets.portlets.navigation.INavigationPortlet" assignment="plone.app.portlets.portlets.navigation.Assignment" renderer=".browser.navi_portlet.navigation_portlet" addview="plone.app.portlets.portlets.navigation.AddForm" editview="plone.app.portlets.portlets.navigation.EditForm" /> <plone:portletRenderer portlet="plone.app.portlets.portlets.navigation.INavigationPortlet" class=".browser.navi_portlet.navigation_portlet" layer=".interfaces.IThemeSpecific" />
renderer = ". browser.navi_portlet.navigation_portlet" here the browser is my folder that contains the navi_portlet file with the navigation_portlet method.
Step 2: navi_portlet.py:
from Products.Five.browser import BrowserView from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile from Products.CMFPlone import PloneMessageFactory as _ from plone.app.portlets.portlets.navigation import Renderer from plone.app.layout.viewlets.common import PersonalBarViewlet from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile from plone.app.layout.globals.interfaces import IViewView class navigation_portlet(Renderer,PersonalBarViewlet): _template= ViewPageTemplateFile('templates/nav_portlet.pt') def nav_up(self): mytal = PersonalBarViewlet.update(self)
what I did in navi_portlet.py, I just inherited the PersonalBarViewlet from the widget (egg folder) and the Renderer from the portlets (egg folder). To override the default behavior, to hide it when you log out.
Step 3: nav_portlet.pt
<dl class="actionMenu deactivated" id="portlet portletNavigationTree" tal:define="user_actions python:view.nav_up();root view/navigation_root" tal:condition="python:view.user_actions and not view.anonymous"> <tal:block condition="not: view/anonymous"> <dt class="portletHeader" tal:attributes="class python:view.hasName() and 'portletHeader' or 'portletHeader hiddenStructure'"> <span class="portletTopLeft"></span> <a href="#" class="tile" tal:attributes="href string:${view/heading_link_target}" tal:content="view/title" i18n:translate="">Navigation</a> <span class="portletTopRight"></span> </dt> <dd class="portletItem lastItem"> <ul class="navTree navTreeLevel0"> <li tal:define="selectedClass view/root_item_class; li_class python:selectedClass and ' navTreeCurrentNode' or ''; normalizeString nocall:context/plone_utils/normalizeString; section_title root/Title; section python:normalizeString(section_title);" tal:condition="view/include_top" tal:attributes="class string:navTreeItem navTreeTopNode${li_class} section-${section}"> <div tal:define="rootIsPortal view/root_is_portal; root_icon view/root_icon; root_type root/portal_type; root_type_class python:'contenttype-' + normalizeString(root_type); root_class python:rootIsPortal and 'contenttype-plone-site' or root_type_class;"> <a tal:attributes="href root/absolute_url; title root/Description; class python:' '.join([root_class, selectedClass]).strip();"> <img tal:replace="structure root_icon/html_tag" tal:condition="not:rootIsPortal" /> <span tal:omit-tag="" tal:condition="rootIsPortal" i18n:translate="tabs_home">Home</span> <span tal:condition="not:rootIsPortal" tal:replace="root/Title">Root item title</span> </a> </div> </li> <li tal:replace="structure view/createNavTree"> SUBTREE </li> </ul> <span class="portletBottomLeft"></span> <span class="portletBottomRight"></span> </dd>
What I tried to do in nav_portlet.pt is to combine both portlets (a navigation portlet using Render (class)) and viewlets (PersonalBarViewlet). so I used the user_action method from the PersonalBarViewlet class (i.etal: condition = "python: view.user_actions, not view.anonymous">) to hide the navigation portlet when logging out.
Hope you all get my points and what I did.
thanks
source share