We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 17855
    • 43 Posts
    admin note This was an issue with MySQL version 5.0.51x

    Hi, I am new today to MODx and have got this far today, FTR it’s so much better than anything I’ve used before!

    I am using ditto to produce one testimonial or quote on the front page of a site.

    [!Ditto? &display=`1` &parents=`7` &randomize=`1` &dateFormat=`%d %b %y`!]


    This ditto call is in the template for the page.

    The results are not being randomized. I have tried increasing the &display to say 5 to see whether ditto just retrieves 1 item but it didn’t make any difference.

    I may be doing something very stupid. but I just cant see it.

    Incidentally when using ditto in debug mode you cant access the debug links when SEO is enabled. Also with multiple ditto’s they don’t seem to work either - this may just be my set up of course.

    Thanks -



      • 25663 MODX Staff
      • 12,272 Posts
      You might want to grab the latest development version from ditto.modxcms.com ... i vaguely recall there being a bug with randomization in earlier versions.
        Ryan Thrash, MODX Co-Founder
        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
        • 17855
        • 43 Posts
        Thanks Ryan - got myself 2.1b3 - but things still not working....

        ’cause I new to all this I guess I dont need any further declarations in my template to get this to work? As it seems to work, albeit without the rand. I guess I dont....

          • 28042 ☆ A M B ☆
          • 24,524 Posts
          I’m using 2.1b3 with this snippet call
          [!Ditto? &id=`quote` &parents=`245` &randomize=`1` &display=`1` &tpl=`quotesTpl`!]

          and it works perfectly. I used the &id parameter because I have another Ditto call displaying the latest news item on the same page.
            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org
            • 17855
            • 43 Posts
            I am thinking perhaps the problem is my testing installation....

            as ditto randomize uses mySQL’s RAND() perhaps there is a problem with the version of MySQL I am using - 5.0.51 on windows.

            I am going to look in to this!
              • 17855
              • 43 Posts
              I solved this problem - below applies to Windows version, I dont know about others.

              The current release of MySQL that is included with XAMPP seems to have RAND() issues which is utilised for &randomize in ditto.

              XAMPP ships 5.0.51 with current release I downloaded and simply installed over with version 5.0.45.

              Everything ok now.

              If you do this remember to back-up first and ignore security warnings in the configuration. The last step will probably throw up password errors with the root acount. Just ignore this.

              Thanks fot the help from all.
                • 19132
                • 199 Posts
                The problem I have with Randomize is that it seems to ignore the cache. It seems it will randomize after 15 minutes. I put a meta tag "nocache" on the template. That didn’t work. I made sure each quote and did you know doc had the Cache? selected and Empty Cache? selected. My code is identical to Susan’s but.... it’s like 15 minutes before I get a new quote and did you know. Is it because I have two randomize calls on the same page?? I don’t think so because they have different parents.
                  MySQL: 5.0.45
                  PHP: 5.2.6
                  Linux 2.6.9-023stab048.6-enterprise #1
                  cURL enabled
                  PDO enabled
                  FFox Apple 3.6.8
                  Firebug DIS-abled
                  • 27305
                  • 173 Posts
                  I have mysql 5.0.22 and the randomize just throws up the first document my call is

                  [!Ditto? &tpl=`extra-content` &startID=`977` display=`1` &randomize=’1’  !]

                  Doh I just noticed that &randomize=’1’ should be tickmarks, now who feels like a muppet
                    I made my first site with modx
                    ------------------------
                    Shopping blog
                    Sky+ HD
                    • 19132
                    • 199 Posts
                    I finally got randomize to work. The key for me was to have a single template. If you have the same randomize call in 2 or more templates, the templates don’t "talk" to each other to find out what the last random bit was, they just throw it up there regardless.
                      MySQL: 5.0.45
                      PHP: 5.2.6
                      Linux 2.6.9-023stab048.6-enterprise #1
                      cURL enabled
                      PDO enabled
                      FFox Apple 3.6.8
                      Firebug DIS-abled