We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 7923
    • 4,213 Posts
    Hi,

    Should ditto be able to sort by multiple tv fields? I tried it, but at least mine copy doesn’t.. I use the SVN version. Tried &sortBy=`tv1,tv2` but debug showed that it sorts by createdon.



      "He can have a lollipop any time he wants to. That's what it means to be a programmer."
      • 18397
      • 3,250 Posts
      Ditto currently does not sort by more than one field. If you feel this feature should be included in future editions please file a ticket @ the TRAC site. It is possible to sort by more than one field by manually adding calls to $ditto->customSort() for each in the snippet code.
        • 7923
        • 4,213 Posts
        I created a ticked for this, pretty essential thing I would think.. I’ll look at using customSort() in the meanwhile, Thanks!


          "He can have a lollipop any time he wants to. That's what it means to be a programmer."
          • 18397
          • 3,250 Posts
          I’m thinking of having &sort=`field ASC field2 DESC` like MySQL. What do you think?
            • 7923
            • 4,213 Posts
            I was thinkin &sortBy=`field1,field2` &sortDir=`asc,desc` (or &sortDir=`desc` is descending for all fields), but which ever you like the best is fine with me smiley


              "He can have a lollipop any time he wants to. That's what it means to be a programmer."
              • 18397
              • 3,250 Posts
              Ok, I’ve created a poll on this topic for which format is more intuitive. Please cast your votes now for which format will be used. Thanks wink
                • 21056
                • 327 Posts
                Quote from: Mark at Apr 06, 2007, 09:59 PM

                Ditto currently does not sort by more than one field. If you feel this feature should be included in future editions please file a ticket @ the TRAC site. It is possible to sort by more than one field by manually adding calls to $ditto->customSort() for each in the snippet code.

                Could you give a code example of how this would work?

                Thanks
                  Author: ManagerManager plugin - customise your ModX manager interface

                  Rckt - web development, Sheffield, UK
                  • 18397
                  • 3,250 Posts
                  After
                  $resource = $ditto->getDocuments($documentIDs, $dbFields, $TVs, $sortBy, $sortDir, $showPublishedOnly, 0, $hidePrivate, $where, $queryLimit, $keywords, $randomize);
                  

                  Add
                  $resource = customSort($resource, FIELDS, ORDER);
                  


                  Where fields is a comma separated list of fields and order either ASC or DESC
                    • 17883
                    • 1,039 Posts
                    Is this implemented in the meanwhile? Saw rev1437

                    Sort by multiple fields just like MySQL using the new &orderBy parameter (Closes #46)

                    Does it work with orderby=`tv1 ASC tv2 DESC` for example?

                    edit: Okay, figured it out: Should be

                    orderBy=`tv1 ASC,tv2 DESC`

                    Good work!
                      • 1978
                      • 131 Posts
                      Looked at TRAC - this ticker is reported to be fixed in ditto 2.1 but i didn’t find it in resources.

                      it’s not finished yet?
                        Как русифировать Modx 0.9.6.1(QuickEdit, TinyMCE)
                        QuickEdit под win-1251 без mb_-функций