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

Count of Number of times component is reused in a page

Avatar

Avatar
Validate 1
Level 3
preethamk694748
Level 3

Likes

10 likes

Total Posts

32 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile

Avatar
Validate 1
Level 3
preethamk694748
Level 3

Likes

10 likes

Total Posts

32 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile
preethamk694748
Level 3

30-10-2017

Hi Team. I have a requirement where  i need to have the count of number of times a component is dragged and dropped in a page

Suppose i have a link component and its dialog has a field(say analytics-field)

If i drag and drop component for first time in a page, that analytics-field in link component dialog should be auto-populated with value "Link1"

If i drag and drop component for second time in a page, that analytics-field in link component dialog should be auto-populated with value "Link2"

If i drag and drop component for third time in a page, that analytics-field in link component dialog should be auto-populated with value "Link3"

.

.

.

.If i drag and drop component for nth time in a page, that analytics-field in link component dialog should be auto-populated with value "Linkn"

Any way to achieve this,

Thanks

Replies

Avatar

Avatar
Establish
MVP
Veena_Vikram
MVP

Likes

449 likes

Total Posts

1,024 posts

Correct Reply

116 solutions
Top badges earned
Establish
Coach
Contributor 2
Seeker
Ignite 5
View profile

Avatar
Establish
MVP
Veena_Vikram
MVP

Likes

449 likes

Total Posts

1,024 posts

Correct Reply

116 solutions
Top badges earned
Establish
Coach
Contributor 2
Seeker
Ignite 5
View profile
Veena_Vikram
MVP

30-10-2017

Hi Preetham

     As far as I could understand , this can be achieved only via a custom logic in the back-end. Write a sling model for your component, and in the init method write the query to check the count of the component (Using query builder API, find the component count ) in current-page and  for each count using Properties API and Node set the value of the property you want to manipulate

Below predicates might help

path = <current page path>

type = "nt:unstructured"

resourceType=< relative path of your component> (never start from /apps)

p.limit=-1

Thanks

Veena

Avatar

Avatar
Validate 10
Level 4
mjb54261515
Level 4

Likes

33 likes

Total Posts

132 posts

Correct Reply

32 solutions
Top badges earned
Validate 10
Validate 1
Boost 5
Boost 3
Boost 25
View profile

Avatar
Validate 10
Level 4
mjb54261515
Level 4

Likes

33 likes

Total Posts

132 posts

Correct Reply

32 solutions
Top badges earned
Validate 10
Validate 1
Boost 5
Boost 3
Boost 25
View profile
mjb54261515
Level 4

30-10-2017

This can be achived only with custom logic. There is no particular API to return number of counts.

  • use node iteration logic for jcr node of page path.
  • from there you can compare each node resource Type to your component resource path. it matches then counter+
  • by the end of iteration logic you will have number of times component is used on the page.

Avatar

Avatar
Validate 1
Level 3
preethamk694748
Level 3

Likes

10 likes

Total Posts

32 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile

Avatar
Validate 1
Level 3
preethamk694748
Level 3

Likes

10 likes

Total Posts

32 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile
preethamk694748
Level 3

30-10-2017

Thanks Veena, Will try this and ill come back if im stuck or if i have any doubts

Avatar

Avatar
Establish
MVP
Veena_Vikram
MVP

Likes

449 likes

Total Posts

1,024 posts

Correct Reply

116 solutions
Top badges earned
Establish
Coach
Contributor 2
Seeker
Ignite 5
View profile

Avatar
Establish
MVP
Veena_Vikram
MVP

Likes

449 likes

Total Posts

1,024 posts

Correct Reply

116 solutions
Top badges earned
Establish
Coach
Contributor 2
Seeker
Ignite 5
View profile
Veena_Vikram
MVP

30-10-2017

Sure. Happy to help anytime. Let us know ..

Avatar

Avatar
Validate 1
Level 3
preethamk694748
Level 3

Likes

10 likes

Total Posts

32 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile

Avatar
Validate 1
Level 3
preethamk694748
Level 3

Likes

10 likes

Total Posts

32 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile
preethamk694748
Level 3

30-10-2017

Thanks Bro, Will try and come back to you if im stuck somewhere

Avatar

Avatar
Validate 10
Level 4
mjb54261515
Level 4

Likes

33 likes

Total Posts

132 posts

Correct Reply

32 solutions
Top badges earned
Validate 10
Validate 1
Boost 5
Boost 3
Boost 25
View profile

Avatar
Validate 10
Level 4
mjb54261515
Level 4

Likes

33 likes

Total Posts

132 posts

Correct Reply

32 solutions
Top badges earned
Validate 10
Validate 1
Boost 5
Boost 3
Boost 25
View profile
mjb54261515
Level 4

30-10-2017

Sure cheer. Let me know if ur stuck