Expand my Community achievements bar.

SOLVED

Custom properties in Editable templates.

Avatar

Level 3

Hi,

We are using Static templates as of now, trying to create Editable templates for the same, while doing so, unable to implement custom properties for the template and <data-sly-test> conditions for the same. how can we achieve the same.?

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Add custom properties in the template dialog, it's almost as same as extending the core component. You need to extend the core page component.

Once you have your own page component then create a template-type where the sling:resourceType will be your new page component. After that using this template-type create your template.

 

If you don't add the custom properties then it's a fault of your page component dialog XML.

<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:granite="http://www.adobe.com/jcr/granite/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,core.wcm.components.page.v3.editor,cq.wcm.msm.properties,granite.contexthub.configuration,cq.siteadmin.admin.properties,core.wcm.components.image.v3.editor]"
    helpPath="https://www.adobe.com/go/aem_cmp_page_v3"
    mode="edit"
    trackingFeature="core-components:page:v3">
    <content
        granite:class="cq-dialog-content-page"
        jcr:primaryType="nt:unstructured"
        sling:resourceType="granite/ui/components/coral/foundation/container">
        <items jcr:primaryType="nt:unstructured">
            <tabs
                granite:class="cq-siteadmin-admin-properties-tabs"
                jcr:primaryType="nt:unstructured"
                sling:resourceType="granite/ui/components/coral/foundation/tabs"
                size="L">
                <items jcr:primaryType="nt:unstructured">
                    <!-- Basic Tab -->
                    <!-- Advance Tab -->
                    <!-- SEO Tab -->
                </items>
            </tabs>
        </items>
    </content>
</jcr:root>

You need to add an override code of XML to add the custom properties and your data-sly-test will work.
These all are the generic information. Let me know if you are looking for any specific information.

View solution in original post

3 Replies

Avatar

Correct answer by
Community Advisor

Add custom properties in the template dialog, it's almost as same as extending the core component. You need to extend the core page component.

Once you have your own page component then create a template-type where the sling:resourceType will be your new page component. After that using this template-type create your template.

 

If you don't add the custom properties then it's a fault of your page component dialog XML.

<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:granite="http://www.adobe.com/jcr/granite/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,core.wcm.components.page.v3.editor,cq.wcm.msm.properties,granite.contexthub.configuration,cq.siteadmin.admin.properties,core.wcm.components.image.v3.editor]"
    helpPath="https://www.adobe.com/go/aem_cmp_page_v3"
    mode="edit"
    trackingFeature="core-components:page:v3">
    <content
        granite:class="cq-dialog-content-page"
        jcr:primaryType="nt:unstructured"
        sling:resourceType="granite/ui/components/coral/foundation/container">
        <items jcr:primaryType="nt:unstructured">
            <tabs
                granite:class="cq-siteadmin-admin-properties-tabs"
                jcr:primaryType="nt:unstructured"
                sling:resourceType="granite/ui/components/coral/foundation/tabs"
                size="L">
                <items jcr:primaryType="nt:unstructured">
                    <!-- Basic Tab -->
                    <!-- Advance Tab -->
                    <!-- SEO Tab -->
                </items>
            </tabs>
        </items>
    </content>
</jcr:root>

You need to add an override code of XML to add the custom properties and your data-sly-test will work.
These all are the generic information. Let me know if you are looking for any specific information.

Avatar

Level 4

The first step to this modernization should be to analyze the structure and properties of all static templates and then take decision on how many Editable Templates you will need.

We now have a responsive grid, thus the recommendation is to keep the number of templates as low as possible.

Responsive grid can then be used by authors to determine the structure and layout of the page/template.

Regarding the custom properties, which will now have to a create a new page component, extending from core page component.

The cq:dialog of this page component, can be leveraged to add all custom properties.

The page component should then be used to create a template type.

From the template type, you should create templates (based on unique structure/policies/initial content required).

<data-sly-test> conditions on the page level can be written in the page component HTML.

For dialog "granite:render" conditions can be used.

The /etc/design data has to be mapped to policies and so on.

The question is very generic, I would be able to help more if you are looking for something specific.

Avatar

Community Advisor

Hello @Aj_9625932 

 

Could you please elaborate what you mean by Custom properties for the template?

 

Sharing few notes regarding default-properties and policies. Please have a look if it helps:

1. All Editable templates would use page component. So, if we want any custom properties, these need to be added to the dialog of page component.

 

2. For any default values for pages created by a template, we can use "Initial page properties" from Edit Template UI

 

3. Also, policies can be added to components, to create template specific configs for that component.


Aanchal Sikka