在CQ对话框中添加课堂上的Textfield
如果我们想将ID添加到诸如image
之类的AEM核心组件中,则有一个字段:
.content.xml ,
<id
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/form/textfield"
fieldDescription="HTML ID attribute to apply to the component."
fieldLabel="ID"
name="./id"/>
它在对话框中提供了此文本字段。
但是,如果我们要创建相同的文本字段,但是对于课程怎么办?核心组件似乎仅使用“ ./id”名称,而没有用于课堂。
如您所见,我是一个绝对的初学者,因此,任何指针或帮助都非常感谢。
---编辑(2022年6月17日):
在弗拉德的回答之后,我需要缩小问题的位置:
我不知道该怎么办”为课堂添加一个文本字段“”。例如,ID字段在XML中具有name =“ ./ ID”
,可以在HTML中以“ $ {image.Id}”访问。但是课堂不存在。
如果我在上课上添加它,Textfield会如何?像这样,显然不会因为“ ./ class”
无法连接到任何地方。
<class
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/form/textfield"
fieldDescription="HTML CLASS attribute to apply to the component."
fieldLabel="CLASS"
name="./class"/>
我猜我的文本字段的name =“ ./ ID”
与某些Java逻辑相关,因此我们可以通过“ $ {image.id}”来检索它。我已经看了看图像的Java代码,但看不到它们如何捆绑在一起。
我需要了解Java代码才能覆盖它。还是我缺少任何东西,有一种更简单的方法?同样,这里绝对是初学者。
If we want to add an Id to an AEM Core component such as image
, there is this field:
.content.xml
<id
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/form/textfield"
fieldDescription="HTML ID attribute to apply to the component."
fieldLabel="ID"
name="./id"/>
which gives this textfield in the dialog.
But what if we want to create the same textfield, but for CLASSES instead? The core components only seems to use the "./id" name, and nothing for classes.
As you can see I am an absolute beginner, so any pointer or help is much appreciated.
--- Edit (June 17, 2022):
Following Vlad's answer, I needed to narrow down where I am having issue:
I don't know how to "add a textfield for classes". For example, the id field has name="./id"
in the xml, which can be accessed as "${image.id}"
in the html. But the same doesn't exist for Classes.
How would the Textfield look like if I am adding it for Classes? Like this one obviously wouldn't work as "./class"
is not connected to anywhere.
<class
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/form/textfield"
fieldDescription="HTML CLASS attribute to apply to the component."
fieldLabel="CLASS"
name="./class"/>
I guess that the name="./id"
of the Textfield is tied to some Java logic so we can retrieve it via "${image.id}"
. I have looked at image's java code, but don't see how they tied together.
I would need to understand the Java code in order to override it. Or am I missing anything and there is an easier way? Again, absolute beginner here.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以覆盖对话框并为类添加文本字段,然后覆盖HTL脚本并将类注入标记中。但是,我建议您首先查看ootb 样式系统。它允许您在组件策略中定义类,然后在编辑器中使用它们(将它们添加到组件包装元素上)。
You can override the dialog and add a textfield for classes, then overlay the HTL script and inject the classes in the markup. However, I recommend you look first into the OOTB Style System. It allows you to define classes in the component’s policy and then use them in the editor (they will be added on the component wrapper element).