2
votes

I'm trying, in Adobe CQ 5.6.1, to build a menu listing components added to a page. These components will have an id and I will anchor-link to these so the page will scroll down to them respectively.

The problem is i get them in scrambled order.

If I laborate in the query builder and with the local Geometrixx site (so you can follow, if you have a local instance of CQ running) this would be an example of a similar query, picking images and text components from the products page:

http://localhost:4502/libs/cq/search/content/querydebug.html?charset=UTF-8&query=type%3Dnt%3Aunstructured%0D%0Apath%3D%2Fcontent%2Fgeometrixx%2Fen%2Fproducts%2Fjcr%3Acontent%0D%0Aproperty%3Dsling%3AresourceType%0D%0Aproperty.1_value%3Dfoundation%2Fcomponents%2Fimage%0D%0Aproperty.2_value%3Dfoundation%2Fcomponents%2Ftext%0D%0Aorderby%3D%40jcr%3AlastModified%0D%0Aorderby.sort%3Dasc

I'm not at all interested in ordering them by jcr:lastModified, I want the order they are presented on the page.

Does anyone have any idea what to order by?

1
I was looking into a similar issue where I wanted a list of references at the bottom of the page. The references had a corresponding number in the preceding contents of the page (basically how Wikipedia does references). The best solution I came up with, was to handle it client side. Build the list of jump links (your anchor links) with javascript that looks at the list of id'ed contents. This way the jump links can be in whatever order you decide.Woodifer
I got another comment (in another forum) to not use the query builder, but rather iterating over the nodes. I will probably give that a try, I think this should be solved backend if possible.primavera133

1 Answers

2
votes

Following on from your comment, iterating over the components seems to be the easiest way.

Assuming you have the id stored as a property, on successive iteration of each component node, you would seek to extract this id and store it into a list.

This would ensure the order as you require, and you can then display the id as links.