简体   繁体   English

如何在Adobe CQ5中设置全局属性

[英]How to set global properties in adobe cq5

I'm developing components on adobe cq5 and need some help/advice. 我正在用Adobe CQ5开发组件,需要一些帮助/建议。 I would like to create a phone number component part of which uses phone number prefixes. 我想创建一个电话号码组件,其中一部分使用电话号码前缀。 I want a page author to be able to set the range of prefixes (ie they need to be content managed), but I don't want them to have to re-specify this list every time they add a phone number component. 我希望页面作者能够设置前缀范围(即,需要对内容进行管理),但是我不希望他们每次添加电话号码组件时都必须重新指定此列表。 The list of prefixes needs to be globally maintained not component level properties. 前缀列表需要全局维护,而不是组件级属性。 I know how to set and use component level properties but not global ones. 我知道如何设置和使用组件级属性,但不能设置和使用全局属性。 Can someone tell me how or point me in the right direction of an example? 有人可以告诉我如何或为我指明示例的正确方向吗?

Have you thought about using design dialog instead of edit dialog? 您是否考虑过使用设计对话框而不是编辑对话框? This can solve your problem. 这样可以解决您的问题。 There is some info regarding this topic. 还有就是关于这个话题的一些信息。

Part of the creation of a dialog is that you are assigning a name which provides the dialog the understanding of where you want to store the values. 对话框创建的一部分是为您分配一个name ,该name使对话框了解您要在何处存储值。

This is usually in the form of ./foo what people forget is that the name field is a path specification. 人们通常会忘记以./foo的形式表示name字段是路径规范。 You could equally specify a name of /global/data/phoneprefixes which would provide the feature that you are looking for. 您可以同样指定/global/data/phoneprefixes的名称,该名称将提供您要查找的功能。

To then use this data, from your code, you would need to look in the same place. 要使用这些数据,您需要从代码中查找相同的位置。 The properties object wouldn't have it at this point since it's only providing the relational properties of the resource you're on. 目前,属性对象尚无此对象,因为它仅提供您所使用资源的关系属性。

If you can't use design dialog for any reason i think the other option could be using the Reference component. 如果由于某种原因您不能使用设计对话框,我认为另一个选择可能是使用参考组件。

https://docs.adobe.com/docs/en/aem/6-0/author/page-authoring/default-components/editmode.html#Reference https://docs.adobe.com/docs/zh-CN/aem/6-0/author/page-authoring/default-components/editmode.html#Reference

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM