the getRelated snippet by default sorts the output in descending order, from newest to oldest. How do you achieve the opposite: ascending from Oldest to Newest?
thanks in advance.
-
- 24,544 Posts
Try this:
or if you're sorting by a TV:
Thanks for the response.
I've tried &fieldSortDir=`asc` before posting. Doesn't solve it. I'm not using TV to sort either
-
- 24,544 Posts
That should definitely work according to the docs.
Are you sending a &fieldSort property? It may not look at the direction property without that.
Also, the sort directions in xPDO are uppercase, so try 'ASC'.
Strangely, the xPDO query default is 'ASC' but the getRelated default is 'desc'. By default, getRelated sorts on createdon, is that what you're using?
[ed. note: BobRay last edited this post 10 years, 8 months ago.]
you mean createdon. The docs state the &fieldSort default is used if not specified, so I didn't declare any.
tried the uppercase: ASC without any difference in output.
-
- 24,544 Posts
Yes, I did mean createdon. Did you try adding the &fieldSort property? It's worth a shot, imo, since nothing else has worked.
BTW, looking at the code, I don't see any way what you're doing could not work.
The only other things I can think of are a missing question mark in the snippet tag, not calling the snippet uncached after making a change, and a misspelled property name.
-
- 24,544 Posts
Yes, apparently it doesn't support sorting.
What exactly are you trying to do? Maybe there's another way.
I have a set of resources under a parent. Now those resources actual hold the profiles of the company's management team. They were input starting from the highest hierarchy but since getRelated (by defualt) sorts by placing the newest resources at the top of the list, you have the most junior team member at the top and the bosses at the base (which is not the other it should be).
getResources would have achieve this sorting but I don't know why it just doesn't work for me any more as it used to. I get no output (this has occured on my last three MODx projects). So I ran to getRelated as alternative.
-
- 24,544 Posts
OK, I think getting getResources to work would be a much better plan. Tell getResources to sort by menuindex and drag them to the order you want in the tree.
If your getResources tag is not working at all, paste it here.