We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 33372
    • 1,611 Posts
    I’m having a hard time getting just the latest document from a series of folders... The documents are news articles, and they’re organized in subfolders by year. Unfortunately, instead of creating them from oldest to newest, we started with the new ones and worked back, so we can’t use createdon usefully (note to self: from now on always add dated material beginning with the oldest!).

    The folders are like so:

    • 2008 (68)
    • 2007 (67)
    • 2006 (65)
    • 2005 (64)
    • 2004 (63)
    • 2003 (62)
    • ...and on back to 1998, but that doesn’t much matter
    and each article within these subfolders has an alias based on its date (e.g., "10-03" or "02-12").

    So I thought I could just grab all of the docs in each of these folders and sort them first by parent id and then by alias, and that would always give me the latest article (matching a tag, etc.). But it’s not working as I expect. I’m getting documents from the oldest folders first.

    This is my Ditto call:
    [[Ditto? &parents=`68,67,65,64,63,62` &summarize=`1` &total=`1` &tpl=`newsblurb` &paginate=`0` &alwaysshow=`1` &sortBy=`parent,alias` &sortDir=`DESC` &displayArchive=`0` &depth=`1` &trunc=`0` &tagDelimiter=`,` &tagData=`tvtags` &tagMode=`onlyTags` &tags=`[*menutitle*]`]]


    Anyone understand why this is happening (and even better how to resolve it or get the results that I need using some other method)? I guess I could go back through them all and add published dates and sort by those, but I’d really rather not have to do that. There’s gotta be a way to make this work!
      "Things are not what they appear to be; nor are they otherwise." - Buddha

      "Well, gee, Buddha - that wasn't very helpful..." - ZAP

      Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options
      • 18397
      • 3,250 Posts
      In Ditto 2.1, you need to use the &orderBy field to sort by mutliple parameters. So, you should remove &sortBy and &sortDir and use &orderBy=`parent DESC,alias DESC`. Then it should sort first by parent id and then by alias.
        • 10449
        • 956 Posts
        Maybe you could also use this query http://modxcms.com/lastUpdate-1558.html and add a WHERE clause (WHERE parent=n1 OR n2 OR n3).

        Installing the latest Ditto version is certainly a better idea though smiley
          • 33372
          • 1,611 Posts
          Quote from: Mark at Feb 24, 2008, 11:45 PM

          In Ditto 2.1, you need to use the &orderBy field to sort by mutliple parameters. So, you should remove &sortBy and &sortDir and use &orderBy=`parent DESC,alias DESC`. Then it should sort first by parent id and then by alias.
          Sweet! I was just using the old parameters (even though I have the latest Ditto). Thanks as always for the quick help!
            "Things are not what they appear to be; nor are they otherwise." - Buddha

            "Well, gee, Buddha - that wasn't very helpful..." - ZAP

            Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options
            • 33372
            • 1,611 Posts
            Rats! It’s still not working for me. I have Ditto 2.1 (latest from the repositories), and my call is the following:
            [[Ditto? &parents=`68,67,65,64,63` &summarize=`2` &total=`2` &tpl=`newsheadline` &paginate=`0` &alwaysshow=`1` &orderBy=`parent DESC,alias DESC` &displayArchive=`0` &depth=`1` &trunc=`0` &tagDelimiter=`,` &tagData=`tvtags` &tagMode=`onlyTags` &tags=`[*menutitle*]`]]

            What’s odd is I’m getting exactly the opposite of what I’d expect: The oldest articles instead of the latest (it does seem to be ordering by both parent and alias, but not the way I want it to). I tried changing DESC to ASC to see if that helped, but it didn’t make any difference. Could there be a bug in the way that the sort order is parsed out of the orderBy parameter?
              "Things are not what they appear to be; nor are they otherwise." - Buddha

              "Well, gee, Buddha - that wasn't very helpful..." - ZAP

              Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options
              • 18397
              • 3,250 Posts
              Could you please provide the Ditto debug data?
                • 33372
                • 1,611 Posts
                How do I get the debug console to work? I set debug to 1 and I get Open Debug Console and Save Debug Console links where my Ditto call is, but the open link just shows the same page in a pop-up and I can’t figure out where the save link saves anything. What am I missing?
                  "Things are not what they appear to be; nor are they otherwise." - Buddha

                  "Well, gee, Buddha - that wasn't very helpful..." - ZAP

                  Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options
                  • 18397
                  • 3,250 Posts
                  Give an uncached call a try.
                    • 33372
                    • 1,611 Posts
                    Can I just say how incredibly slick that debug console is? Dang! The data is attached.

                    EDIT: Original attachment had an incorrect parameter that I was using temporarily.
                      "Things are not what they appear to be; nor are they otherwise." - Buddha

                      "Well, gee, Buddha - that wasn't very helpful..." - ZAP

                      Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options
                      • 18397
                      • 3,250 Posts
                      According to your debug output, Ditto is properly sorting both in DESC order. Can you try removing the tagging parameters and see if things work?