cancel
Showing results for 
Search instead for 
Did you mean: 

Sorting <#list> by name

eventime
Champ in-the-making
Champ in-the-making
I've got a annoying issue I've not been able to solve for the life of me. In one of our FreeMarker .ftl template files, there exists a <#list>

<#list dom.DocumentList.Document as doc>
     <table width="100%" class="form"> 
          <tr>
               <td width="90%">${doc.DocumentName}</td>
               <td width="10%"><a href="${doc.File.FileLink}">Open PDF</a></td>
          </tr>
     </table>  
</#list>
The Document is simply a file that's been uploaded through Alfresco, and there are no extra custom properties or anything, just   
       Name:   
       Content Type:
       Encoding:
       Title:
       Description:
       Author:
       Size:   
       Creator:
       Created Date:
       Modifier:
       Modified Date:

All I want to do is sort the list by the name of the file (aka alphabetically). That's it. I've tried everything I can find online. How can I do this?
And please, do not give me a ?sort_by(['properties','cm:name']), as it was the first thing I tried, and got a ?sort_by(…) failed: Values used for sorting must be numbers, strings, or date/time values
Everything else has failed (hell, even ?sort doesn't work) (and what the hell does cm:name (aside from the obvious) actually mean, and *where* does one find those values anyways? I could never find an explanation anywhere)

Any assistance would be most helpful.
Thanks
4 REPLIES 4

mikeh
Star Contributor
Star Contributor
Did you try ?sort_by('name')  ?

Mike

eventime
Champ in-the-making
Champ in-the-making
I've tried that one already, and get a  "?sort_by(…) failed: Values used for sorting must be numbers, strings, or date/time values" (followed by the standard issue stack trace) in the log file.
There must be something simple I'm overlooking.

mikeh
Star Contributor
Star Contributor
Hmm… looking back at your code, I'm not sure what objects are in your dom.DocumentList.Document sequence.

However, you seem to be accessing doc.DocumentName so ?sort_by('DocumentName') should be a winner.

Mike

eventime
Champ in-the-making
Champ in-the-making
Good sir, you just made my day. That worked. I'm quite annoyed at myself, as I'd tried everything, BUT that one. Thank you very much.