仅显示特定文件夹的操作

发布于 2024-11-06 04:22:32 字数 228 浏览 2 评论 0原文

我在 /mysite/portal_actions/object/rename 添加了自定义 CMF 操作。 “条件(表达式)”字段的值为 python:plone_context_state.is_folderish() 或 plone_context_state.is_default_page(),这使得操作在每个文件夹的选项卡上可见。我希望它仅显示在folder1、folder2 和folder3 的选项卡上。条件字段应该使用什么?

I have added a custom CMF Action at /mysite/portal_actions/object/rename. The value for "Condition (Expression)" field is python:plone_context_state.is_folderish() or plone_context_state.is_default_page(), that makes the action visible on every folder's tab. I want it show only on tabs of folder1, folder2 and folder3. What should I use for Condition field?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

半葬歌 2024-11-13 04:22:32

您有多种选择;条件表达式几乎可以无限扩展。

按文件夹 id

显而易见的测试是测试一组文件夹 id:

python:(plone_context_state.is_folderish() or plone_context_state.is_default_page()) and
        folder.getId() in ('folder1', 'folder2', 'folder3')

使用 collective.flag

collective.flag 让您的内容编辑者确定选项卡应显示的位置。它向您的内容添加了一个简单的布尔复选框,您可以轻松测试文件夹上设置的该标志。该标志仅显示在具有正确接口的内容类型上,因此您可以轻松执行此操作。

python:(plone_context_state.is_folderish() or plone_context_state.is_default_page()) and 
        folder.restrictedTraverse('@@plone_interface_info').provides('collective.flag.interfaces.IFlaggableObject')

使用脚本测试

您可以使用任何可获取的方法进行测试,包括皮肤中的 Python 脚本。这不是最佳实践,但它可能会给您带来所需的额外灵活性。

python:(plone_context_state.is_folderish() or plone_context_state.is_default_page()) and
        folder.yourScriptName()

只需记住测试文件夹上的条件即可。

You have several options; the condition expression can be extended almost infinitely.

By folder id

The obvious test would be to test for a set of folder ids:

python:(plone_context_state.is_folderish() or plone_context_state.is_default_page()) and
        folder.getId() in ('folder1', 'folder2', 'folder3')

Use collective.flag

collective.flag let's your content editors determine where the tab should show up. It adds a simple boolean checkbox to your content, and you could easily test for that flag being set on your folders. The flag only shows up on content types that have the correct interface, so you could easily do this

python:(plone_context_state.is_folderish() or plone_context_state.is_default_page()) and 
        folder.restrictedTraverse('@@plone_interface_info').provides('collective.flag.interfaces.IFlaggableObject')

Use a script test

You can use any acquirable method for your test, including a Python script in the skin. Not the best practice, but it may just give you the extra flexibility you need.

python:(plone_context_state.is_folderish() or plone_context_state.is_default_page()) and
        folder.yourScriptName()

Just remember to test for conditions on folder.

一场信仰旅途 2024-11-13 04:22:32

python:(plone_context_state.is_folderish() 和 (object.getId() == 'folder1' 或 object.getId() == 'folder2' 或 object.getId() == 'folder3')) 或 (plone_context_state.is_default_page( ) 和 (plone_context_state.parent.getId() == 'folder1' 或plone_context_state.parent.getId() == 'folder2' 或 plone_context_state.parent.getId() == 'folder3'))

像这样。您可以使用文件夹路径来确保它们正是这些文件夹,而不仅仅是具有这些 ID 的文件夹。

python:(plone_context_state.is_folderish() and (object.getId() == 'folder1' or object.getId() == 'folder2' or object.getId() == 'folder3')) or (plone_context_state.is_default_page() and (plone_context_state.parent.getId() == 'folder1' or plone_context_state.parent.getId() == 'folder2' or plone_context_state.parent.getId() == 'folder3'))

something like this. You can use the folder path to be sure they're exacly those folders and not just folders with those ids.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文