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
  • 3375 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

I may explain it in an unclear way. The component xml is actually in _cq_dialog/.content.xml, something like this:

 

mysite/components/navigation/_cq_dialog/.content.xml

<xml...>

<jcr:root..>

      <content ...>

           <item>

               

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

          </item>

      </content>

</jcr:root>

 

The RTE doesn't show up.