将CQ5组件设置为可编辑或不可编辑(Set a CQ5 component to editable or not editable)

编程入门 行业动态 更新时间:2024-10-28 17:28:46
将CQ5组件设置为可编辑或不可编辑(Set a CQ5 component to editable or not editable)

如果我想在页面A中设置可编辑的cq5组件,但在页面B中不可编辑,是否可行。

例如:在页面A,我有C组件,我们允许作者打开对话框并编辑组件。 但我们不允许作者打开对话框来编辑第B页上的组件C.我尝试研究cq:EditConfig 链接 ,但这还不足以解决我的问题。

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.

最满意答案

您可以在include之前设置ComponentContext.BYPASS_COMPONENT_HANDLING_ON_INCLUDE_ATTRIBUTE,并在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

您可以编写Sling组件过滤器:

您可以检查页面和组件,如果要禁用编辑,只需设置属性,执行过滤器,然后取消设置属性...

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

更多推荐

本文发布于:2023-07-24 17:18:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1248822.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:编辑   设置为   组件   component   Set

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!