将CQ5组件设置为可编辑或不可编辑 [英] Set a CQ5 component to editable or not editable
问题描述
如果我想在页面A中设置可编辑的cq5组件,但在页面B中不可编辑,是否可行。
Is it posible if i want to set a cq5 component editable in page A, but not editable in page B.
例如:在页面A,我有C组件我们允许作者打开对话框并编辑组件。但我们不允许作者打开对话框来编辑B页上的组件C.
我尝试研究cq:EditConfig 链接,但这还不足以解决我的问题。
For example: at page A, i have C component we allow authors to open dialog and edit the component. But we do not allow authors to open dialog to edit component C on Page B. I try to research cq:EditConfig link, but It's not enough documentation to resolve my issue.
推荐答案
您可以在include之前设置ComponentContext.BYPASS_COMPONENT_HANDLING_ON_INCLUDE_ATTRIBUTE,并在include之后将其删除。
You can set ComponentContext.BYPASS_COMPONENT_HANDLING_ON_INCLUDE_ATTRIBUTE before the include, and remove it after the include.
设置:
slingRequest.setAttribute(ComponentContext.BYPASS_COMPONENT_HANDLING_ON_INCLUDE_ATTRIBUTE, true);
删除:
slingRequest.removeAttribute(ComponentContext.BYPASS_COMPONENT_HANDLING_ON_INCLUDE_ATTRIBUTE);
更多详情请点击此处: https://dev.day.com/docs/en/cq/current/developing/boilerplates.html
More details are here: https://dev.day.com/docs/en/cq/current/developing/boilerplates.html
您可以编写Sling组件过滤器:
You can write a Sling component filter:
您可以检查页面和组件,如果您愿意禁用编辑,只需设置属性,执行过滤,然后取消设置属性......
And you can check the page and the component, and if you want to disable editing, just set the attribute, do the filter, and unset the attribute...
这篇关于将CQ5组件设置为可编辑或不可编辑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!