Set a CQ5 component to editable or not editable

跟風遠走 提交于 2019-11-30 18:24:40

问题


Is it posible if i want to set a cq5 component editable in page A, but not editable in page B.

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.


回答1:


You can set ComponentContext.BYPASS_COMPONENT_HANDLING_ON_INCLUDE_ATTRIBUTE before the include, and remove it after the include.

Set:

slingRequest.setAttribute(ComponentContext.BYPASS_COMPONENT_HANDLING_ON_INCLUDE_ATTRIBUTE, true); 

Remove:

slingRequest.removeAttribute(ComponentContext.BYPASS_COMPONENT_HANDLING_ON_INCLUDE_ATTRIBUTE);

More details are here: https://dev.day.com/docs/en/cq/current/developing/boilerplates.html

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...



来源:https://stackoverflow.com/questions/22341140/set-a-cq5-component-to-editable-or-not-editable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!