Ditto`s orderBy

on 20-Feb-2010 | Comments ( 5 ) Tags: Ditto, Evolution

According to the documentation orderBy is

"An array that holds all criteria to sort the result set by."

An example would be:

[[Ditto? &orderBy=`pagetitle ASC`]]

You can accomplish the same thing using the sortDir and sortBy:

[[Ditto? &sortBy=`pagetitle` &sortDir=`ASC`]]

What you can't do with the above is use multiple criterias to sort your data.

Imagine you want to sort your documents based on the city and country TVs. For this to work you need to specify two sort criterias. With orderBy you can easily do it like:

[[Ditto? &orderBy=`city ASC, country DESC`]]

where city and country are 2 TVs associated with your template.

The orderBy parameter can also be used as a shorthand to sortBy and sortDir.

 

Do you know any other Ditto tips? Share them below.

Write a comment

  • Required fields are marked with *.

If you have trouble reading the code, click on the code itself to generate a new random code.
 
mary
Posts: 4
Comment
Re: Ditto`s orderBy
Reply #5 on : Sat February 20, 2010, 13:02:39
Very nice, I didn't know this, thanks!
Frank Los
Posts: 4
Comment
sortBy menuindex
Reply #4 on : Sun April 11, 2010, 08:09:03
Hi is that still possible, sorting by menuIndex.

Thanks, Frank Los-
cipa
Posts: 1
Comment
Re: Ditto`s orderBy
Reply #3 on : Sun April 11, 2010, 08:34:35
It should should work the same way.

I never tried something like
&orderBy=`index ASC, country DESC`
as it doesn't really make sense.
Jako
Posts: 4
Comment
Re: Ditto`s orderBy
Reply #2 on : Tue April 27, 2010, 16:09:20
Don't try to use orderBy and only sortDir together. This will cause Ditto to sort by orderBy=`createdon 'sortDir-parameter', 'orderBy-parameter'`
Lalith Herath
Posts: 4
Comment
Paginate in ditto
Reply #1 on : Mon November 15, 2010, 22:18:15
How to put pagination in Ditto

Quick modx Evolution Tags

  • cached [[snippet]] or uncached [!snippet!]
  • {{chunk}}
  • [+placeholder+]
  • [*resourceField/TV*]
  • [^timing^]
  • [~link~]

Quick modx Revolution Tags

  • [[snippet]]
  • [[$chunk]]
  • [[+placeholder]]
  • [[*resourceField/TV]]
  • [[~link]]
  • [^timing^]
  • [[++systemSetting]]
  • [[%languageStringKey]]
  • all tags can be called un-cached like: [[! snippet]]

Timing Tags (Evo and Revo)

  • [^qt^] - Query time
  • [^q^] - Query count
  • [^p^] - Parse time
  • [^t^] - Total time
  • [^s^] - Source
© modxRULES! 2009-2014