在CQ / AEM中禁用组件编辑 [英] Disable component editing in CQ/AEM

查看:102
本文介绍了在CQ / AEM中禁用组件编辑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在很多情况下,我都有一个使用cq:include来包含组件B的组件A。A和B都是可编辑的,并且都有对话框。但是,当B包含在A中时,我想禁用对组件B的直接编辑-我将通过A的对话框来管理创作。我已经看到了几种方法可以实现此目的。第一个是

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); %>

第二个是

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

我的理解是,第一个将子组件置于父级的编辑上下文中,第二个将子组件完全没有孩子的编辑上下文。但是我不确定区别到底意味着什么。据我所知,唯一的主要区别是,第一个仅影响下一个组件包含,而第二个影响两行之间的所有包含。生成的标记也略有不同。但是除此之外,对话框似乎具有相同的行为。我的POC可能太简单了,看不到它们之间的差异... cq:EditConfig节点中是否有会受到影响的值?还有其他区别吗?

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?

谢谢

推荐答案

您也可以只是swtich WCMMode包含的关闭编辑模式:

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);%>

这将使B像在没有任何编辑功能的情况下在发布服务器上呈现一样。

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

这篇关于在CQ / AEM中禁用组件编辑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆