We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 6228
    • 249 Posts
    I have a Ditto call that fetches a set of documents as follows:

    [!Ditto? &documents=`244,243,61,113,197` &tpl=`rotatorContentBlock` !]

    The returned set of documents is sorted by document id by default.

    Is there a way to inhibit sorting, so that the document set returned is in the order specified in the documents parameter, from left to right? So for example, the above ditto call would return a set with 244 being the first, 243 second, and the last document being 197.

    Many thanks.

    -Mike

    Evo 1.0.3
    Ditto 2.1.0
      lo9on.com

      MODx Evolution/Revolution | Remote Desktop Training | Development
      • 6228
      • 249 Posts
      Too bad nobody could post a simple solution :’(

      After a day’s worth of experimentation hacking the snippet, I couldn’t find a practical way of getting this seemingly simple functionality to work. Every time I succeeded at circumventing document ordering, another class method would find a way of reordering them. It was maddening.

      Anyway, off to the next task at hand.

      - Mike
        lo9on.com

        MODx Evolution/Revolution | Remote Desktop Training | Development
        • 16278
        • 928 Posts
        I don’t think there is a simple solution without any coding, because when Ditto orders things it is using the MySQL ORDERBY parameter, which needs to be given a field to sort by. The documents list isn’t a field, so it can’t do it. The default order you’re getting is not the document ID, it’s the createdon date.

        On the other hand, I was pretty sure I have seen this requirement being met before, and a google search for "modx ditto sort by document list" took me here:
        http://modxcms.com/forums/index.php?topic=47947.0
        grin KP
          • 6228
          • 249 Posts
          Great catch! I troweled a few boards looking for a solution, but I should have searched the entire forum embarrassed
            lo9on.com

            MODx Evolution/Revolution | Remote Desktop Training | Development
            • 12092
            • 5 Posts
            I just looked in the modx_site_content table and used the menuindex column to sort...

            &orderBy=`menuindex ASC`
              • 37076
              • 12 Posts
              If you are planning an ordered ditto call with selected docs,
              and if the docs are in different folders,
              and they are already being used in their folder menu,
              their folder menu indexing will be a mess.

              I have a very simple solution for this smiley

              just make an individual ditto call for each document and put them in any order you want smiley

              [[Ditto? &documents=`1` &tpl=`rotatorContentBlock` ]]
              [[Ditto? &documents=`12` &tpl=`rotatorContentBlock` ]]
              [[Ditto? &documents=`512` &tpl=`rotatorContentBlock` ]]
              [[Ditto? &documents=`224` &tpl=`rotatorContentBlock` ]]
              


              but try to keep the your item list short wink [ed. note: wzavhpem last edited this post 14 years, 11 months ago.]