Hi,
I have a requirement to get a list of 3 most recent page crated in cq5 so that i can create their list .
Plz help me to understand how to achieve this. I need to work on this on urgent basis. plz help me.
how would be the sample query.
Thanks,
Amit
Solved! Go to Solution.
Hi there Amit,
You can sort the entries by their property: "jcr:created".
The query for this (you can e.g. check in the debugger) would be:
path=/content/mysite/ type=cq:Page orderby=@jcr:content/jcr:created orderby.sort=desc
Or if you want it in java code:
Map map = new HashMap(); map.put("path", "/content/mysite"); map.put("type", "cq:Page"); map.put("orderby", "@jcr:content/jcr:created"); map.put("orderby.sort", "desc"); Query query = builder.createQuery(PredicateGroup.create(map), session); SearchResult result = query.getResult();
Hope that will help you
/Johan
Hi there Amit,
You can sort the entries by their property: "jcr:created".
The query for this (you can e.g. check in the debugger) would be:
path=/content/mysite/ type=cq:Page orderby=@jcr:content/jcr:created orderby.sort=desc
Or if you want it in java code:
Map map = new HashMap(); map.put("path", "/content/mysite"); map.put("type", "cq:Page"); map.put("orderby", "@jcr:content/jcr:created"); map.put("orderby.sort", "desc"); Query query = builder.createQuery(PredicateGroup.create(map), session); SearchResult result = query.getResult();
Hope that will help you
/Johan