Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

page sorting on siteadmin

Avatar

Level 4

Hi,

is it possible to order pages in a certain way through site admin and then when we do an xpath search retain the order we defined through siteadmin for results we find through xpath search.

 

Thanks 

Chris 

1 Accepted Solution

Avatar

Correct answer by
Level 10

Usually you don't have a search when you want the node order and can simply use navigational access (node.getNodes()) in that case. Example at [1] and then in logic you can apply filter.   

In Jackrabbit/CRX you can globally configure "respectDocumentOrder" for the query index, which is turned off by default, since it is expensive. It would have effect on queries w/o any order by statement (and might only affect xpath & sql). There is no explicit order by document order statement at all. 

[1]

<%
Resource r = slingRequest.getResourceResolver().getResource( "/content/geometrixx/en");
Node rootNode = r.adaptTo(Node.class);
NodeIterator it = rootNode.getNodes();
while(it.hasNext()){
Node node = it.nextNode();
%>
<%=node.getName()%>
<%
}
%>

View solution in original post

7 Replies

Avatar

Level 10

Can you please provide more details on what you want to do. You want to use SiteAdmin to order pages? 

Avatar

Level 4

I want to use siteadmin to order pages in a certain way eg 

 

page1 - has a property called foods

page3  - has a property called games

page4  - has a property called drinks

page9 -  has a property called games

page10 -  - has a property called foods

 

I would like to now write a servlet to search for foods and games

 

I would like the order to be retained as 

page1 - has a property called foods

page3  - has a property called games

page9 -  has a property called games

page10 -  - has a property called foods

Avatar

Level 10

Your requirement does not look like sorting. It is about filtering. You can meet it using [1] & might be additional filtering. 

[1]   http://dev.day.com/docs/en/cq/current/developing/customize_siteadmin.html

Avatar

Level 4

what I want to do is use querymanager to select from a particular path and get all the pages in that. 

However I want the result to retain the node ordering you see inside jcr

 

eg

news page

     --> news page 3

    --> news page 1

   --> news page 3

 

when I run my query using querymanager I want to retain the above order in the queryresults

Avatar

Correct answer by
Level 10

Usually you don't have a search when you want the node order and can simply use navigational access (node.getNodes()) in that case. Example at [1] and then in logic you can apply filter.   

In Jackrabbit/CRX you can globally configure "respectDocumentOrder" for the query index, which is turned off by default, since it is expensive. It would have effect on queries w/o any order by statement (and might only affect xpath & sql). There is no explicit order by document order statement at all. 

[1]

<%
Resource r = slingRequest.getResourceResolver().getResource( "/content/geometrixx/en");
Node rootNode = r.adaptTo(Node.class);
NodeIterator it = rootNode.getNodes();
while(it.hasNext()){
Node node = it.nextNode();
%>
<%=node.getName()%>
<%
}
%>

Avatar

Level 4

Hi Thanks,

 

If I was to do node.getNodes() how heavy a call is this compared to me doing a search use querymanager with all the filters applied?

 

thanks

Avatar

Level 10

it all deponds on your structure & number of nodes.  respectDocumentOrder will surely be expensive compared to node.getNodes()