Disable component editing in CQ/AEM

让人想犯罪 __ 提交于 2019-12-11 04:12:58

问题


I've got a variety of situations where I have a component A which uses cq:include to include component B. Both A and B are editable and have dialogs. However, when B is included in A, I'd like to disable direct editing of component B - I'll manage the authoring through A's dialog. I've seen a couple methods that accomplish this. The first is

<% IncludeOptions.getOptions(request, true).forceSameContext(true); %>

and the second is

<% slingRequest.setAttribute(ComponentContext.BYPASS_COMPONENT_HANDLING_ON_INCLUDE_ATTRIBUTE, true); %>
<% slingRequest.removeAttribute(ComponentContext.BYPASS_COMPONENT_HANDLING_ON_INCLUDE_ATTRIBUTE);  %>

My understanding is that the first forces the child component into the parent's editing context, and the second just creates no editing context for the child at all. But I'm not sure what the difference really means. As far as I can tell, the only major difference is that the first one only affects the next component include, while the second one affects all includes between the two lines. There's also a minor difference in the markup generated. But beyond that, the dialogs seem to behave the same way. It's possible that my POC is just too simple to see the differences...are there values in a cq:EditConfig node that would be affected? Some other difference?

Thanks


回答1:


You can also just swtich off edit mode for an include with the WCMMode:

<%WCMMode prevMode = WCMMode.DISABLED.toRequest(request);%>
    <cq:include path="b" resourceType="B" />
<%prevMode.toRequest(request);%>

This will render B like it would be rendered on a publish server without any edit functionality.



来源:https://stackoverflow.com/questions/31188701/disable-component-editing-in-cq-aem

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