Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

teaserDelegate resource returning null

Avatar

Level 2

 

I have defined teaserDelegate on list component node

-- sling:resourceSuperType="core/wcm/components/list/v2/list"

 --   teaserDelegate="core/wcm/components/teaser/v1/teaser"

 

My page in the list item has teaser image, however when I call item

${item.teaserResource} there is no resource, it is coming as null. How do we configure list component to use teaserDelegate? Is there any step I am missing?

 

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

So if I good understand, you would like to get data from teaser that is located on different page. In that case you will probably need some custom component/solution, teaser delegate will show page metadata as teaser but it will not look for the teaser component on that page.

View solution in original post

4 Replies

Avatar

Community Advisor

Hi @mohammedahmed, to use teaserDelegate list feature you need to use v3 of list component and v2 of teaser.

<my-list
    jcr:primaryType="cq:Component"
    componentGroup="My Group"
    cq:isContainer="{Boolean}false"
    jcr:title="My List Component"
    sling:resourceSuperType="core/wcm/components/list/v3/list"
    teaserDelegate="core/wcm/components/teaser/v2/teaser"/>

If your component is configured correctly you will see additional option that will allow to display list items as teaser.

list-teaser-delegate-dialog.jpg

I am not sure which version of Core Compnents you are using but I would suggest to use the latest one. You can observe that v2 of list component is using following ListItem implementation https://github.com/adobe/aem-core-wcm-components/blob/development/bundles/core/src/main/java/com/ado... - which is not providing any implementation of getTeaserResource() method so default value - null is returned.

You can also check ListItem implementation used by v3 list https://github.com/adobe/aem-core-wcm-components/blob/development/bundles/core/src/main/java/com/ado... - as you can see this version contains getTeaserResource() method fully implemented.

Avatar

Level 2

Thank you @lukasz-m

I do see the option now. I am more interested in the image path on the teaser item. I am getting the resource now with the path --/content/mysite/mypage1/jcr:content however my teaser is at -- /content/mysite/mypage1/jcr:content/root/container/container/teaser

Is there any OOTB api we can use to get this path or we have to write some additional class to get the resource and appropriate field.

 

 

Avatar

Correct answer by
Community Advisor

So if I good understand, you would like to get data from teaser that is located on different page. In that case you will probably need some custom component/solution, teaser delegate will show page metadata as teaser but it will not look for the teaser component on that page.

Avatar

Level 1

I am not sure what page core component version you are using but if you supply a featured image in the properties, that will auto populate in your list when you select "display as a teaser". Otherwise you would need to write custom code to grab the image in another teaser on the page.