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

    I’ve used ditto to sort a list of items by stock number. I would like the secondary sort criteria to be by product status [*productAvailability*]. I’m sure this is simple, but I haven’t been able to figure out how to do it. Here’s how my code looks:

    [[Ditto? &startID=`2` &hideFolders=`1` &depth=`100` &tpl=`miniProduct` &display=`all` &paginate=`1` &sortBy=`productStock`  &sortDir=`ASC` &paginateAlwaysShowLinks=`0` &debug=`0` &extenders=`request` &tplPaginatePage=`page` &tplPaginateCurrentPage=`currentPage` &tagDelimiter=`,` &tagData=`productFilters` &tagMode=`onlyAllTags` &tags=`mannequins,abstract`]]


    Thanks for any help!

    - Ruben
      • 5340
      • 1,624 Posts
      I do not think Ditto can do that. Maybe there is a newer version that can, but I have no idea.

      Your best bet is to build a custom snippet with custom query.

        • 16545
        • 358 Posts
        If your ditto version is 2.1, you can try use &orderBy=`ASC productStock,productAvailability`, without using sortBy and sortDir
          • 5340
          • 1,624 Posts
          Hi labasus,

          Where can I find documentation for 2.1? I only have it for 2.0.1

          Thx
            • 25678
            • 36 Posts
            Thanks labasus. I tried it but unfortunately, it doesn’t work. It just gives me a modx parse error. Hmmm....
              • 16278
              • 928 Posts
              Documentation for Ditto 2.1 parameters is on the Ditto support site: http://ditto.modxcms.com/files/snippet-ditto-php.html

              That page is not very forthcoming on &orderBy, but I’ve experimented with multiple sorts and it works with a list of comma-separated pairs of fields and directions:
              &orderBy=`productStock ASC, productAvailability DESC`
              You always need to state the direction with &orderBy, unlike &sortBy which defaults to DESC if no sortDir is given.
              cool KP