Expand my Community achievements bar.

SOLVED

How to restrict number of component

Avatar

Level 4

Hi ,

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

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

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.

 

kishorekumar14_0-1629710117016.png

 

View solution in original post

6 Replies

Avatar

Community Advisor

@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

Avatar

Level 4

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

 

Avatar

Community Advisor

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

Avatar

Correct answer by
Community Advisor

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.

 

kishorekumar14_0-1629710117016.png

 

Avatar

Community Advisor

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!

Avatar

Level 1

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