Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何覆盖Plone';特殊情况内容的显示菜单?_Plone - Fatal编程技术网

如何覆盖Plone';特殊情况内容的显示菜单?

如何覆盖Plone';特殊情况内容的显示菜单?,plone,Plone,要获得Plone文件夹的一次性视图,我可以执行以下操作(并非所有代码都显示): 在configure.zcml中: <!-- Marker interface. Set this on the folder through the ZMI interfaces tab. --> <interface interface=".interfaces.IMySpecialFolder" /> <!-- Special case view. Set as t

要获得Plone文件夹的一次性视图,我可以执行以下操作(并非所有代码都显示):

configure.zcml
中:

<!-- Marker interface. Set this on the folder through the ZMI
     interfaces tab.
  -->
<interface interface=".interfaces.IMySpecialFolder" />
<!-- Special case view. Set as the folder's view through the ZMI
     properties tab (layout property).
  -->
<browser:page
  for="..interfaces.IMySpecialFolder"
  name="special"
  template="special.pt"
  permission="zope2.View"
  />
<include package="plone.app.contentmenu" />

<browser:menuItem
  for="..interfaces.IMySpecialFolder"
  menu="plone_displayviews"
  title="Special view"
  action="@@special"
  description="Special case folder view"
  />
<?xml version="1.0"?>
<object name="Folder">
 <property name="view_methods" purge="False">
  <element value="special"/>
 </property>
</object>
这非常有效,但我想控制文件夹的显示菜单,使其仅列出我的特例视图。我可以添加它,它只显示在我标记的文件夹中,但我必须更改站点范围的文件夹ATFTI

浏览器/configure.zcml
中:

<!-- Marker interface. Set this on the folder through the ZMI
     interfaces tab.
  -->
<interface interface=".interfaces.IMySpecialFolder" />
<!-- Special case view. Set as the folder's view through the ZMI
     properties tab (layout property).
  -->
<browser:page
  for="..interfaces.IMySpecialFolder"
  name="special"
  template="special.pt"
  permission="zope2.View"
  />
<include package="plone.app.contentmenu" />

<browser:menuItem
  for="..interfaces.IMySpecialFolder"
  menu="plone_displayviews"
  title="Special view"
  action="@@special"
  description="Special case folder view"
  />
<?xml version="1.0"?>
<object name="Folder">
 <property name="view_methods" purge="False">
  <element value="special"/>
 </property>
</object>
当然,如果不影响站点上的每个文件夹,我无法删除现有的可用视图方法

有没有一种方法可以在不改变内容类型FTI的情况下一次性调整显示菜单

事实上,这个问题似乎以前已经解决过。修补程序
cmfdynamicalyviewfti
以从
idynamicalyviewable
适配器查找中获取可用视图的列表。(将此机制用于其文件夹日历视图)。所以我的问题变成:


有没有一种方法可以在不更改内容类型的FTI和不修补Plone的情况下一次性调整显示菜单?

Plone显示菜单生成器使用
ISelectableBrowserDefault
获取显示菜单中的可用选项(请参阅 )

因此,我认为(但我没有尝试过)如果您为提供
Products.cmfdynamicsviewfti.interface.ISelectableBrowserDefault
的更具体的接口(在您的例子中是
imysspecialfolder
)定义一个适配器,它应该可以工作


适配器应该具有上面
plone.app.contentmenu.menu.DisplayMenu
所要求的方法。

回答我自己的问题,我已经意识到,实现一次性文件夹视图最直接的方法是遵循Plone本身在
Members
文件夹中应用的模式:调用自定义视图的PythonScript
index\u html
,例如

member_search=context.restrictedTraverse('member_search_form')
return member_search()
Products.CMFPlone

回想起来,我意识到在我的提问场景中我不需要marker接口。答案中也没有这个必要


请注意,这个解决方案不会像我所说的那样导致“文件夹的显示菜单只列出我的特例视图”,而是完全取消了显示菜单。我对此没意见。

解决这个问题的一种方法是使用traversalhook注册菜单项,或者在本例中,取消注册菜单项,或者使用使菜单项不出现的条件注册菜单项。有了遍历钩子,您可以使用一个标记接口使它只发生在某个文件夹、子部分或页面中。 您可以在这里看到我们在哪里实现了类似的代码


在这种情况下,我们只想根据控制面板配置动态注册新的显示菜单项。

ISelectableBrowserDefault
只是一个源;显示菜单代码也会查看上下文本身,这些方法仍然会参考FTI。请阅读和。后者是用作原型基类的混合,因此您不能轻松地将其用于适配器,但您可以从适配器委派对它的调用。@martijn pieters:我阅读了实现,但我的答案中的链接指向使用适配器的contentmenu实现。所以我认为它应该能工作。@marcosfromero我确认它会很好地工作,我想给OP额外的资源。
ISelectableBrowserDefault的接口定义及其具体实现的链接是为了补充您的答案,而不是批评它!:-)谢谢@marcosfromero和@MartijnPieters,但我无法获得一个ISelectableBrowserDefault适配器“take”。甚至尝试使用
for=“*”
期望ZCA报告冲突,但没有。你能自己试一试吗?