您可以像在 Classic 中一样重复使用 Touch 中的选项卡,方法是使用 granite/ui/components/foundation/include 和 path 属性。
在下面的示例中,我们有一个标题组件,其中包括一个普通的文本小部件并拉入一个可重用的组件设置选项卡。我已将共享选项卡放在/apps/mysite/dialogs/granite/tabs 下,但这不是必需的,您可以简单地更新path 属性。
这是/apps/mysite/components/heading/_cq_dialog.xml的组件对话框:
<?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="Heading"
sling:resourceType="cq/gui/components/authoring/dialog"
helpPath="en/cq/current/wcm/default_components.html#Carousel">
<content
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/container">
<layout
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/layouts/tabs"
type="nav"/>
<items jcr:primaryType="nt:unstructured">
<generalSettings
jcr:primaryType="nt:unstructured"
jcr:title="General Settings"
sling:resourceType="granite/ui/components/foundation/section">
<layout
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/layouts/fixedcolumns"/>
<items jcr:primaryType="nt:unstructured">
<column
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/container">
<items jcr:primaryType="nt:unstructured">
<headingText
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/form/textfield"
fieldLabel="Text"
name="./text"/>
</items>
</column>
</items>
</generalSettings>
<componentSettings
jcr:title="Component Settings"
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/include"
path="mysite/dialogs/granite/tabs/componentSettings"/>
</items>
</content>
</jcr:root>
可重复使用的组件设置选项卡位于/apps/mysite/dialogs/granite/tabs/componentSettings.xml:
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/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="Settings"
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">
<componentId
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/form/textfield"
fieldLabel="Component Id"
name="./componentId"/>
</items>
</column>
</items>
</jcr:root>