How to restrict number of component | Community
Skip to main content
Level 4
August 23, 2021
Solved

How to restrict number of component

  • August 23, 2021
  • 2 replies
  • 2203 views

Hi ,

I have inherited core carousel component to add specific component but how to restrict number of component ?

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 Kishore_Kumar_

Hi @lone_ranger ,

 

To restrict only one component to your carousel component, click on the Carousel Component Policy icon  and choose that particular component alone in Allowed Components List.

 

 

2 replies

Bhuwan_B
Community Advisor
Community Advisor
August 23, 2021

@lone_ranger Please follow below Steps to acheive your usecase:

https://github.com/adobe/aem-core-wcm-components/issues/471

  • Create a proxy carousel component
  • Add a tab to the policy dialog with a numberfield to set the max limit
  • Add a data attribute set with the max limit in the HTML of the proxy component
  • In the clientlib of the proxy component, add the frontend logic that displays the warn message and prevents from adding more slides
  • Add the clientlib to the edit dialog of your proxy component
Level 4
August 23, 2021

How i can include only 1 component which is available in my project rather than setting a limit?

 

Bhuwan_B
Community Advisor
Community Advisor
August 23, 2021

@lone_ranger Allowed components can be configured through policy configuration. Configure Policy to add only your Project specific Component.

Ritesh_Mittal
Community Advisor and Adobe Champion
Community Advisor and Adobe Champion
August 23, 2021

Hi @lone_ranger ,

 

To achieve maximum number client side validation, you have to add custom script, which I would not recommend because of maintenance of backward compatibility for future component updates. Instead of that you can display an author friendly message in authoring mode while author configures the component to suggest/warn that the component works better for max 3 components.

 

You will find a details description in below video-

https://www.youtube.com/watch?v=675WXqyGeII

 

Hope it helps!

April 4, 2022

Hi Ritesh,

 

I am also looking to set max limit of components that can be added in carousel component, the youtube video that you have added is removed. Could you please provide me the link with detail to implement the same.

 

Thanks

Arpitha P