We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 17723
    • 221 Posts
    Hi !
    I’ve spend last 2 hours figuring out how to sort my menuindex in desc dir. It seams that sorting doesn’t work whatsoever.
    Im using modx 9.6.3 with Ditto 2.1
    I’ve tried all types of sorting and non is working  >:(.
    Some of my Ditto calls:
    [!Ditto? &parents=`44` &tpl=`newsTpl` &dateFormat=`%d/%m/%y` &orderBy=`menuindex DESC` &display=`all` &hideFolders=`1` &noResults=` `!]
    I’ve tryed also the old method of sorting by using &sortBy=`menuindex` &sortDir=`DESC` and it does’t work eighter .

    I was using sorting with ditto on previous projects (and modx versions) and had no problem.

    Heeeeelppp please !!!
      Lucas from AroundCyprus.net
      • 1122
      • 209 Posts
      You have not mentioned about the database server version. Described symptoms indicate that probably you are using MySQL v. 5.0.51 -- it contains a bug and this issue was extensively discussed in earlier threads.
        • 20413
        • 2,877 Posts
        Try add &dateSource with createdon, editedon or pub_date and call the snippet cached [[...]]
          @hawproductions | http://mrhaw.com/

          Infograph: MODX Advanced Install in 7 steps:
          http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

          Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
          http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
          • 17723
          • 221 Posts
          Hi,
          mySql version is 5.0.51a-log and PHP 5.2.2.
          lx
            Lucas from AroundCyprus.net
            • 17723
            • 221 Posts
            Thank You Alki for indicating the problem.
            It was a MySql 5.0.5 bug (ORDER BY not working with GROUP BY).

            I’ve applyed some changes to ditto.class.inc.pl as posted here http://modxcms.com/forums/index.php/topic,6320.15.html by funkafize:

            edditing assets\snippets\ditto\classes\ditto.class.inc.php line 915

            $sql = "SELECT DISTINCT $fields FROM $tblsc sc
            LEFT JOIN $tbldg dg on dg.document = sc.id
            WHERE sc.id IN (" . join($ids, ",") . ") $published AND sc.deleted=$deleted $where
            ".($public ? ’AND (’.$access.’)’ : ’’)." GROUP BY ".($sort ? " $sort " : " sc.id ") .
            ($sort ? " ORDER BY $sort" : ""). " $limit ";

            the bold part was : ".($public ? ’AND (’.$access.’)’ : ’’)." GROUP BY sc.id" . --->So always was grouping by id


            Right now sorting works prefectly.

            PROBLEM SOLVED !
              Lucas from AroundCyprus.net