AEM Добавить новую вкладку в диалог интерфейса сенсорного интерфейса компонента страницы OOTB

Я хочу добавить новую вкладку в диалоговое окно сенсорного интерфейса компонента страницы OOTB (/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>

Спасибо!

1 ответ

Причина, по которой вы не видите остальные вкладки компонента базовой страницы, заключается в том, что вы overlaying корень items узел всех вкладок. При наложении вы переопределяете функциональность libs компонент и дает приоритет над наложенным компонентом. Если вы хотите иметь и остальные вкладки, вам придется скопировать их все в наложенный компонент, что крайне не рекомендуется, поскольку вы потеряете при обновлении компонента при обновлении AEM или установке службы пакует вниз по линии.

Я бы посоветовал 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>

Скриншот

Подробнее об иерархии компонентов и наследовании здесь

Другие вопросы по тегам