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

    Let’s say I have 14 documents to display. I use paginate=`1` and &summarize=`7` so that I display them on 2 pages.
    Now, I want to sort them by id. Look what it outputs :

    Page 1 : (numbers are id)
    91, 84, 83, 82, 80, 78, 77

    Page 2 :
    97, 94, 90, 89, 88, 87, 86

    In fact on each page, it sorts well but if you look globally, sorting is not good. I would have liked to get

    Page 1 :
    97, 94, 91, 90, 89, 88, 87

    Page 2 :
    86, 84, 83, 82, 80, 78, 77

    It looks like paginate is done before sorting. Is there a way to sort before paginating so that I get what I need ?

    Thank you for your help smiley

    Perrine
      • 18397
      • 3,250 Posts
      I just checked on my install of 0.9.2.2 and sortBy=`id` with sortDir=`ASC` and DESC works fine on my test install with over 1,500 documents. Are you sure your parameters were camel case?
        • 23050
        • 1,842 Posts
        Camel case ? mmm, don’t understand undecided

        Here is my call :

        [!Ditto? &startID=`[*parent*]` &tpl=`MenuEnCoursReaLi` &summarize=`7` &paginate=`1`  &sortBy=`menuindex` &tplPaginateNext=`MenuEnCoursReaNext` &tplPaginatePrevious=`MenuEnCoursReaPrevious` !]


        I tried with &sortBy=`id` and `menuindex` and none worked.

        Here is the page where I run Ditto : http://www.architecture-gambino.com/v2/index.php?id=6
        (Numbers below links are menuindex)

        If I change SortDir with DESC and ASC, sort changes but only in each page &stat=0, &start=7 and &start=14.
        Not in the whole menu

        PS : I run 0.9.5 RC2
          • 11975
          • 2,542 Posts
          Camel case ? mmm, don’t understand

          hellomynameisperrine <= Camel case =>helloMyNameIsPerrine

          <french>
          C’est une sorte de convention dans la dénomination des variables
          Elle facilite la mise en valeur des différentes composantes du nom
          </french>

          :-)
            Made with MODx : [url=http://www.copadel.com]copadel, fruits et l
            • 23050
            • 1,842 Posts
            Well... Problem still persists. I’ve tried several things but nothing worked so I’m testing to run a fresh install to see if the problem is still here.

            I’ll tell you when it’s done wink
              • 18397
              • 3,250 Posts
              Make sure you try in MODx 0.9.2.2 because that will let me know if it is an issue with Ditto or something with your host or db.
                • 23050
                • 1,842 Posts
                Well... I’ve installed 0.9.2.2 and created 5 documents (3,4,5,6,7) in a folder (2)

                Here is what I tested :

                1-
                [!Ditto? &startID=`2` &summarize=`3` &paginate=`1` &tpl=`MenuEnCoursReaLi` &sortDir=`DESC` &sortBy=`id`!]


                It outputs :
                Page 1 : 5 - 4 - 3
                Page 2 : 7 - 6

                2-
                [!Ditto? &startID=`2` &summarize=`10` &paginate=`0` &tpl=`MenuEnCoursReaLi` &sortDir=`DESC` &sortBy=`id`!]


                It outputs :
                Page 1 : 7 - 6 - 5 - 4 - 3

                With pagination call, Ditto seems to paginate first and then sort.

                I have MySQL 4.1.21. I’ve read the bug about sorting problem with this version of MySQL. I checked that the fix AntonL gives in his post is done on my 0.9.5 installation.

                Tell me if I can help you more Mark wink

                I’m going to test now with MySQL 4.0.25 rolleyes
                  • 23050
                  • 1,842 Posts
                  Yeah... I found it ! It comes from MySQL 4.1.21 !

                  It works perfect on MySQL 4.0.25 (MODx 0.9.2.2, Ditto 1.1 beta 2)

                  So now : any idea on how to fix it with MySQL 4.1.21 ? Or do I have to tell my client he has to change his MySQL version ? grin
                    • 18397
                    • 3,250 Posts
                    Ditto uses the MODx API for most SQL functions so you will need to change MySQL versions.
                      • 10357
                      • 573 Posts
                      try adding &sortDir=`DESC` &sortBy=`publishedon` to you ditto call. worked for me grin