Extend the core carousel component Model for reading the child items. | Community
Skip to main content
Level 2
April 3, 2023
Solved

Extend the core carousel component Model for reading the child items.

  • April 3, 2023
  • 2 replies
  • 3162 views

Hello All,

 

I have a requirment to overlay carousel core component and add custom components to it. Here I want to update the carousel items reading logic.

Could please any one help to where we need to update the code. i don't see any method for reading child items in carousel sling model class.

 only sling model expoter is showing the data in edit mode.

below image contains 3 images (item_***) inside carousel.  i want to perform some logic on item nodes and return the list to carousel. 

 

 

Appriciate for your help.

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

@sady_rifat , 

if possible could you please share the package if you done earlier.  when i call customCarousel from htl ,  Authoring expirence got broken .

 

it's really helpfull if you can share the package.


Hello @naresh536 ,
I just created a fresh project with the below command,

mvn -B org.apache.maven.plugins:maven-archetype-plugin:3.2.1:generate \ -D archetypeGroupId=com.adobe.aem \ -D archetypeArtifactId=aem-project-archetype \ -D archetypeVersion=40 \ -D appTitle="My Project" \ -D appId="my-project" \ -D groupId="com.my.project" \ -D artifactId="my-project" \ -D package="com.my.project" \ -D version="0.0.1-SNAPSHOT" \ -D aemVersion="6.5.14"

 

Here is the link to how you can customize the tab container Items: https://github.com/Sady-Rifat/my-project 

 

 

2 replies

walterch
April 3, 2023

Look at the getItems() Method inherited from Container-Model. It is also used by the htl to iterate trough the children.

Naresh536Author
Level 2
April 3, 2023

@walterch , 

 

Could you please explain from where this container model is calling from carousel htl. 

 

Sady_Rifat
Community Advisor
Community Advisor
April 4, 2023

Hello, the carousel component was inherited from the PanelContainer component. That component is responsible for reading the list.

 

See the Caurosel component Model Class that extends the AbstractPanelContainerImpl.

 

public class CarouselImpl extends AbstractPanelContainerImpl implements Carousel

 

https://github.com/adobe/aem-core-wcm-components/blob/main/bundles/core/src/main/java/com/adobe/cq/wcm/core/components/internal/models/v1/CarouselImpl.java

 


Reading List: https://github.com/adobe/aem-core-wcm-components/blob/main/bundles/core/src/main/java/com/adobe/cq/wcm/core/components/internal/models/v1/AbstractPanelContainerImpl.java#L78 

So you need to overwrite the AbstractPanelContainerImpl function.

Naresh536Author
Level 2
April 4, 2023

Hi @sady_rifat ,

 

So we have to override the Carouse and CarouseImpl and AbstractPanelContainerImpl implementations correct.

Could you confirm we have to  override the below. 

public interface Carousel extends PanelContainer {
 

public class CarouselImpl extends AbstractPanelContainerImpl implements Carousel {}

 

If extends the panelContainer we are getting the below 

com.adobe.cq.wcm.core.components.internal.models.v1 can't be resolved.

Could you please help me to resolve.

In general all models/classes located under internal package are not exported by Core Components bundles. This means you cannot use them directly (despite the fact that you can do it on your IDE). 

 

Thanks for help.

Naresh536Author
Level 2
April 6, 2023

Yes. pom up to date. 

version 2.22.0.

 

 


@sady_rifat , 

if possible could you please share the package if you done earlier.  when i call customCarousel from htl ,  Authoring expirence got broken .

 

it's really helpfull if you can share the package.