仅显示特定文件夹的操作
我在 /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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您有多种选择;条件表达式几乎可以无限扩展。
按文件夹 id
显而易见的测试是测试一组文件夹 id:
使用 collective.flag
collective.flag 让您的内容编辑者确定选项卡应显示的位置。它向您的内容添加了一个简单的布尔复选框,您可以轻松测试文件夹上设置的该标志。该标志仅显示在具有正确接口的内容类型上,因此您可以轻松执行此操作。
使用脚本测试
您可以使用任何可获取的方法进行测试,包括皮肤中的 Python 脚本。这不是最佳实践,但它可能会给您带来所需的额外灵活性。
只需记住测试
文件夹
上的条件即可。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:
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
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.
Just remember to test for conditions on
folder
.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.