cancel
Showing results for 
Search instead for 
Did you mean: 

Order by XPATH

ale_carraro
Champ in-the-making
Champ in-the-making
Hi, I'm writing a Custom View, altering the one called
Presentation Templates/recent_docs.ftl

I'm looking for folders, so my XPath query is:
.//*[subtypeOf('cm:folder')]

it works, but it returns the content pseudo-randomly. Is there a way to get the folders ordered by Title, or Name?

thanks Alex
2 REPLIES 2

andy
Champ on-the-rise
Champ on-the-rise
Hi

Lucene queries support ordering by the SearchParameters object. XPATH supports ordering according to the extensions in the JCR 1.0 spec. The availability of this depends on the langauage selected on the call to selectNodes. I am not sure if this is exposed via the template language. You may have to check the wiki docs.

Andy

ale_carraro
Champ in-the-making
Champ in-the-making
I did it: as explained in the freemarker guide, you can sort on sub-properties using the notation ['x','y','z'…] to do a sort by the x.y.z… property.

So getting the folders ordered by name is done in this way:
<#list space.childrenByXPath[".//*[subtypeOf('cm:folder')]"]?sort_by(['properties','name']) as child >