Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn more

View all

Sign in to view all badges

SOLVED

How to restrict number of component

saurabh_kumar_02
Level 2
Level 2

Hi ,

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

1 Accepted Solution
kishorekumar14
Correct answer by
Level 8
Level 8

Hi @saurabh_kumar_02 ,

 

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

5 Replies
Bhuwan_B
Community Advisor
Community Advisor

@saurabh_kumar_02 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
saurabh_kumar_02
Level 2
Level 2

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

 

Bhuwan_B
Community Advisor
Community Advisor

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

kishorekumar14
Correct answer by
Level 8
Level 8

Hi @saurabh_kumar_02 ,

 

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

Ritesh_M
Community Advisor
Community Advisor

Hi @saurabh_kumar_02 ,

 

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!