我的问题非常简单......
在Plone 4(4.2)中我需要设置一个默认视图,例如一个简单的页面,在导航树中显示。
答案 0 :(得分:1)
导航树使用INavigationQueryBuilder
组件查找显示的所有元素。默认实现过滤掉用作默认页面的任何内容。
您必须提供自己的实施方案;但您可以重复使用原始实现。您所要做的就是稍微改变生成的查询;通常,如果不存在更具体的查询,则is_default_page
索引用于过滤掉默认页面。但是,如果您的更改查询添加了对该索引的搜索,那么它将不会尝试添加更具体的过滤器。将其设置为搜索(True, False)
意味着它将返回默认页面和非默认页面,从而有效地中和过滤器。
然后实施变为:
from plone.app.portlets.portlets.navigation import QueryBuilder, INavigationPortlet
from zope.component import adapts
from zope.interface import implements, Interface
class INonDefaultPageFilteringNavigationPortlet(INavigationPortlet):
pass
class DontFilterDefaultQueryBuilder(QueryBuilder):
implements(INavigationQueryBuilder)
adapts(Interface, INavigationPortlet)
def __init__(self, context, portlet):
super(DontFilterDefaultQueryBuilder, self).__init__(context, portlet)
self.query['is_default_page'] = (True, False) # Don't filter out default pages
您必须将此注册为适配器,和将INonDefaultPageFilteringNavigationPortlet
添加到您的portlet以“激活”此构建器:
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:five="http://namespaces.zope.org/five">
<adapter factory=".yourmodule.DontFilterDefaultQueryBuilder" />
<five:implements
class="plone.app.portlets.portlets.navigation.Assignment"
interface=".yourmodule.INonDefaultPageFilteringNavigationPortlet" />
</configure>
所有人都警告说这是未经测试的,但应工作。
答案 1 :(得分:0)
您也可以在文件夹中创建一个链接,将目标设置为“./idOfPage1”并将链接设置为该文件夹的默认视图。
没有编辑权限的用户将被重定向到Page1,然后页面本身将显示在navportlet中。