Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Component in template does not show up in a page

Avatar

Level 4

I am having an issue where a custom component called "metadata" is in a custom template, and shows up in the template editor, but does not appear in the page that is made with the template.

 

Here is the template editor in AEM:

rkody_0-1697052618291.png

"I EXIST" is there showing that the component is in fact in the template. Here is the html of the "metadata" component:

<sly data-sly-use.Metadata="com.project.aem.dita.core.models.Metadata"></sly>
<div class="dita_metadata_group">
    <h1>I EXIST</h1>
    <sly data-sly-test="${Metadata.updatedDate}">
        <p class="prop">${'UPDATED' @ i18n}: <span class="prop_value">${Metadata.updatedDate}</span></p>
    </sly>
    <sly data-sly-test="${Metadata.documentId}">
        <p class="prop">${'DOCUMENT ID' @ i18n}: <span class="prop_value">${Metadata.documentId}</span></p>
    </sly>
</div>

 

However, when a page is created with that template, "I EXIST" does not display. I even debugged my local instance and the component init function never gets called like it does on the template editor page.

protected void initMetadata() throws RepositoryException {
...
}

 

What would cause a component to not display?

 

1 Accepted Solution

Avatar

Correct answer by
Level 4

Thank you for your reply. I figured out that because I was making edits to the template and moving things around, I needed to create a brand new page with the template. I was only testing with a page that was already created with the old version of the template.

 

Creating a new page allowed the metadata component to appear with no issues.

View solution in original post

2 Replies

Avatar

Community Advisor

Hello @rkody 

 

Can you please check if you have cq:template property on the jcr:content node of the Page?

aanchalsikka_0-1697080701682.png

 

If absent, please append and check the component. The property should also be available on template's structure node 

aanchalsikka_2-1697080787824.png

 


Aanchal Sikka

Avatar

Correct answer by
Level 4

Thank you for your reply. I figured out that because I was making edits to the template and moving things around, I needed to create a brand new page with the template. I was only testing with a page that was already created with the old version of the template.

 

Creating a new page allowed the metadata component to appear with no issues.