我想向OOTB页面组件触摸UI对话框(/libs/foundation/components/page
)添加一个新标签,以便从该OOTB组件继承的所有页面都将具有这些字段。
不幸的是,不能将选项卡添加到每个模板组件,因为我正在构建插件而不是实现。
我一直试图覆盖/libs/foundation/components/page/_cq_dialog/content/items/tabs/items/
并仅将我的标签添加到该叶items
节点,但是这样就不会拉出其余的OOTB标签。我认为这是因为它不是叶节点,并且在进行叠加时希望如此。因此,我需要以某种方式将我定义的内容与OOTB touch ui对话框合并。
这是我的/apps/foundation/components/page/_cq_dialog
节点:
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0"
xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
jcr:primaryType="nt:unstructured"
jcr:title="Page"
sling:resourceType="cq/gui/components/authoring/dialog"
extraClientlibs="[cq.common.wcm,cq.siteadmin.admin.properties]"
mode="edit">
<content
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/container"
class="cq-dialog-content-page">
<items jcr:primaryType="nt:unstructured">
<tabs
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/container"
rel="cq-siteadmin-admin-properties-tabs">
<layout
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/layouts/tabs"
type="nav"/>
<items jcr:primaryType="nt:unstructured">
<custom
jcr:primaryType="nt:unstructured"
jcr:title="Custom"
sling:resourceType="granite/ui/components/foundation/section">
<layout
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/layouts/fixedcolumns"
margin="{Boolean}false"/>
<items jcr:primaryType="nt:unstructured">
<column
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/container">
<items jcr:primaryType="nt:unstructured">
<customsection
jcr:primaryType="nt:unstructured"
jcr:title="Custom field"
sling:resourceType="granite/ui/components/foundation/form/fieldset">
<items jcr:primaryType="nt:unstructured">
<customfield
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/form/textfield"
fieldLabel="custom field"
name="customField"/>
</items>
</customsection>
</items>
</column>
</items>
</custom>
</items>
</tabs>
</items>
</content>
</jcr:root>
谢谢!
答案 0 :(得分:2)
您没有从基础页面组件中看到其余选项卡的原因是,您是所有选项卡的overlaying
的根items
节点。覆盖后,您将重新定义libs
组件的功能,并优先使用覆盖的组件。如果您还想拥有其余选项卡,则必须将所有选项卡都复制到叠加的组件中,强烈建议,因为您在升级组件时会迷失方向当您升级AEM或在线安装Service Pack时。
我建议使用extending
组件,而不是在网站的基本页面组件中将sling:resourceType
的值设置为foundation/components/page
。这样,您仅添加了该额外的自定义标签,并从libs
继承了其余标签。极有可能(如果遵循aem最佳实践),您的网站将已经具有具有此属性的基本页面组件,而其余模板将从该组件继承。将以下_cq_dialog
添加到该页面组件,您应该在所有页面上看到新标签。
.content.xml
您的基础页面组件。/apps/<<prj>>/templates
中的主要模板之一将有sling:resourceType
链接到此页面组件。
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
jcr:primaryType="cq:Component"
jcr:title="Base Page Component"
sling:resourceSuperType="foundation/components/page"
componentGroup=".hidden"/>
_cq_dialog-重新使用代码(除了新道具-
sling:orderBefore="cloudservices"
以外,以订购新标签
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
jcr:primaryType="nt:unstructured">
<content jcr:primaryType="nt:unstructured">
<items jcr:primaryType="nt:unstructured">
<tabs jcr:primaryType="nt:unstructured">
<items jcr:primaryType="nt:unstructured">
<custom
jcr:primaryType="nt:unstructured"
jcr:title="Custom"
sling:orderBefore="cloudservices"
sling:resourceType="granite/ui/components/foundation/section">
<layout
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/layouts/fixedcolumns"
margin="{Boolean}false"/>
<items jcr:primaryType="nt:unstructured">
<column
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/container">
<items jcr:primaryType="nt:unstructured">
<customsection
jcr:primaryType="nt:unstructured"
jcr:title="Custom field"
sling:resourceType="granite/ui/components/foundation/form/fieldset">
<items jcr:primaryType="nt:unstructured">
<customfield
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/form/textfield"
fieldLabel="custom field"
name="customField"/>
</items>
</customsection>
</items>
</column>
</items>
</custom>
</items>
</tabs>
</items>
</content>
</jcr:root>
屏幕截图
有关组件层次结构和继承here
的更多信息