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

    I have a client testimonial section on the left of my site which displays 1 document.

    I have it set up so that each document is created under the testimonials page and pulled on to the main testimonial page via ditto.

    What I want is to display one testimonial ( introtext ) onto the left column across the site but do it so it is random and on a page refresh will change the one displayed.

    Is this possible huh

    Thanks for any help
      • 36592
      • 970 Posts
      Ditto has randomize parameter so I think you can do it with another Ditto call.
      http://ditto.modxcms.com/files/snippet-ditto-php.html#randomize
        • 4872
        • 12 Posts
        As alternative solution to randomize parameter of ditto, you could use snippet by doing db query and return introtext field.

        SELECT id, introtext
        FROM `site_content`
        WHERE parent = ’youparentid’ AND isfolder = ’0’
        ORDER BY RAND()
        LIMIT 1

        Be sure to call the snippet with [! !] to make sure it doesn’t not load from cache.
          • 22840
          • 1,572 Posts
          Quote from: tkfm at Sep 26, 2009, 08:39 AM

          Ditto has randomize parameter so I think you can do it with another Ditto call.
          http://ditto.modxcms.com/files/snippet-ditto-php.html#randomize

          Cheers,

          Just what I was looking for grin

          @cevarief,

          Good solution but no need for more complicated methods when ditto already has it built in

            • 22840
            • 1,572 Posts
            Just noticed I’m getting "Resource Array Error " at the bottom of the output using the following call:
            [!Ditto? &tpl=`testimonials` &parents=`21`  &randomize=`1` &limit=`1`!]


            If I remove the &limit=`1` it goes but displays all testimonials.

            Any ideas what could be wrong ??
              • 26931
              • 2,314 Posts
              try
              &queryLimit=`1`
                • 22840
                • 1,572 Posts
                Thanks sharkbait

                Tried that and still the same output embarrassed
                  • 26931
                  • 2,314 Posts
                  hmm...maybe:
                  &total=`1`
                  ?
                    • 36592
                    • 970 Posts
                    If you want only one document to be displayed use this.
                    &display=`1`
                      • 26931
                      • 2,314 Posts
                      If you want only one document to be displayed use this.
                      &display=`1`
                      is &display not supposed to be used with pagination?
                      probably/hopefully both will work smiley