André Ferreira
André Ferreira

Reputation: 11

How to insert the same component more than one time - Adobe CQ

I have an accordion component and I would like to insert an 'parsys' component in each 'tab' of the accordion.

I realized that the 'path' attribute must be different , then I tried to set that dynamically like:

for (Value val : values) {
    i++;
    pathname = PATH + i;
    obj = new JSONObject(val.getString());
%>

'<cq:include path='<%= pathname %>' ...

But it didn't work

I also tried to output this from JSP , but it didn't work either.

Someone know how can I solve it?

Upvotes: 1

Views: 2674

Answers (2)

amitdeol
amitdeol

Reputation: 279

You have three options to set the path dynamically

  1. ${currentNode.identifier} : this will give you the unique id for every node in aem.
  2. ${resource.parent.name}-${resource.name} this will give you a unique Human READABLE Id.
  3. Write a WCM binding class to provide you a unique ID based on the current node path.

Upvotes: 5

Abhinav
Abhinav

Reputation: 21

If you can share the piece of code where you are creating the tabs and putting parsys inside it, it would be easier to advice.

But in absence of code,here you go - While you are looping the list of tabs to be created, you can use the loop index and append it to the path, to create unique paths..

Upvotes: 1

Related Questions