ログアウト後にナビゲーション ポートレットを非表示にする方法 私がまさに望んでいるのは、ログインした管理者がサイトにアクセスした場合、ナビゲーション ポートレットが表示され、管理者が plone サイトからログアウトするまで表示されるようにすることです。しかし、通常のユーザーが plone サイトにアクセスした場合、ポートレットは表示されません。
2 に答える
私の質問に対するすべての応答に感謝します。残念ながら、あなたが提供した解決策は私にはうまくいきません。そこで私自身、ログアウト時にナビゲーションポートレットを非表示にするのが好きでした。
ステップ 1: 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" ここで browser は、メソッド navigation_portlet を持つ navi_portlet というファイルを含むフォルダーです。
ステップ 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)
navi_portlet.py で行ったことは、ビューレット (eggs フォルダー) から PersonalBarViewlet を継承し、ポートレット (eggs フォルダー) から Renderer を継承したことです。デフォルトの動作をオーバーライドして、ログアウト時に非表示にします。
ステップ 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>
私が nav_portlet.pt でやろうとしたことは、ポートレット (Render(class) を使用したナビゲーション ポートレット) とビューレット (PersonalBarViewlet) の両方をマージすることです。PersonalBarViewlet クラス (i.etal:condition="python:view.user_actions and not view.anonymous">) の user_action メソッドを使用して、ログアウト時にナビゲーション ポートレットを非表示にしました。
皆さんが私のポイントと私がしたことを理解してくれることを願っています。
ありがとう