Granite UI component in static template | Community
Skip to main content
Level 5
June 2, 2023

Granite UI component in static template

  • June 2, 2023
  • 1 reply
  • 3400 views

Hi All,

 

Initially I like to include a rich text editor in a container within a component, but it fails to show up. So I just include a regular auto-generated text component, which is located at "mysite/components/content/text". This seems to be for all projects using maven archetype and I take for granted that it works.

 

Here is the component 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="Nav Config"

    sling:resourceType="cq/gui/components/authoring/dialog"

    extraClientlibs="[core.wcm.components.navigation.v1.editor]"

    >

<content

        granite:class="cmp-navigation__editor"

        jcr:primaryType="nt:unstructured"

        sling:resourceType="granite/ui/components/coral/foundation/container">

        <items jcr:primaryType="nt:unstructured">

            <tabs

                jcr:primaryType="nt:unstructured"

                sling:resourceType="granite/ui/components/coral/foundation/tabs"

                maximized="{Boolean}true">

                <items jcr:primaryType="nt:unstructured">

                    <textheading

                    jcr:primaryType="nt:unstructured"

                    id="nav-heading-text"

                    title="Heading &amp; Text"

                    jcr:title="Heading &amp; Text"

                    sling:resourceType="granite/ui/components/coral/foundation/container">

                    <items jcr:primaryType="nt:unstructured">

                        <heading

                            jcr:primaryType="nt:unstructured"

                            fieldLabel="Heading"

                            name="./heading"

                            sling:resourceType="granite/ui/components/foundation/form/textfield"/>

                       

            <text

                            jcr:primaryType="nt:unstructured"

                            fieldLabel="Body"

                            name="./text"                                                             sling:resourceType="mysite/components/content/text">

             </text>

                    </items>

                    </textheading>

                </items>

            </tabs>

        <items>

</content>

</jcr:root>

 

Looking at the bold text xml, the "Heading" and its field show up on the component, but not the "Body". 

If I change the sling:resourceType to "mysite/components/content/separator", I can see the separator, and only this one works, others such as image, title, etc. don't. 

 

The mysite/component/content/text/.content.xml is:

<?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="Text"

    sling:resourceSuperType="core/wcm/components/text/v2/text"

    componentGroup="Mysite.Content"/>

 

Can someone please help?

thanks!

-kt

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

1 reply

EstebanBustamante
Community Advisor and Adobe Champion
Community Advisor and Adobe Champion
June 2, 2023

I think you are confused with the file names. 

The /component/path/.content.xml is meant to be the component definition, you cannot add dialog code in there.

The /component/path/_cq_dialog/.content.xml  is meant to be the dialog's definition.

 

That being said, I think you could potentially use the RTE in the dialog instead of trying to embed the text component, simply use in the dialog definition something like this:

<richTextEditor jcr:primaryType="nt:unstructured" sling:resourceType="cq/gui/components/authoring/dialog/richtext" name="./text">

 

 

Esteban Bustamante
Kevin_GTaAuthor
Level 5
June 3, 2023
<items jcr:primaryType="nt:unstructured"> <heading jcr:primaryType="nt:unstructured" fieldLabel="Heading" name="./heading" sling:resourceType="granite/ui/components/foundation/form/textfield"/> <text jcr:primaryType="nt:unstructured" sling:resourceType="cq/gui/components/authoring/dialog/richtext" name="./text" useFixedInlineToolbar="{Boolean}true" > <rtePlugins jcr:primaryType="nt:unstructured"> <format jcr:primaryType="nt:unstructured" features="bold,italic"/> </rtePlugins> <uiSettings jcr:primaryType="nt:unstructured"> <cui jcr:primaryType="nt:unstructured"> <inline jcr:primaryType="nt:unstructured" toolbar="[format#bold,format#italic,format#underline,links#modifylink,links#unlink]"> </inline> <icons jcr:primaryType="nt:unstructured"> <bold jcr:primaryType="nt:unstructured" command="format#bold" icon="textItalic"/> </icons> </cui> </uiSettings> </text> <descp jcr:primaryType="nt:unstructured" fieldLabel="Description" name="./description" sling:resourceType="granite/ui/components/foundation/form/textfield"/> </items>

 

I am attaching a screenshot here, showing the two text fields but not the RTE. 

 

EstebanBustamante
Community Advisor and Adobe Champion
Community Advisor and Adobe Champion
June 6, 2023

You may see all the nodes are created accordingly. 

 

 


Try something of these:

- Use the text component from the Core components in your pages

- Drop your component into other templates/sites (wknd site may work due it has enabled the clientlibs)

- Inspect the dialog to check there is no custom code hiding the RTE field

- Check if you have any policy which could be messing with your component.

 

These can give you some insights if the issue is related to your template, site, clientlibs, or any other custom code, it seems the code i shared works just fine (i just double checked in wknd site), so it may be something specific to you 😕😕 

Esteban Bustamante