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

    Bit of a strange one, ill explain basically I have a page with 12 images listed but actually have 20 of these images/documents in the manager under "Projects", but for display purposes I ask DITTO to display 12 only, but also I would like it to randomize them in the page load, now this is the problem, how do i get it to only display the first 12 from the database, so I can always show the newest ones, but radomnize them on the page??

    This is my ditto call so far: [[Ditto? &parents=`3` &display=`12` &randomize=`1` &tpl=`workpreview`]]

    Any advice would be great smiley

    Brett
      • 4172
      • 5,888 Posts
      try this one:

      [!Ditto? &documents=`[[Ditto? &parents=`3` &display=`12` &tpl=`@CODE[+id+],`]]` &display=`all` &randomize=`1` &tpl=`workpreview`!]
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 22969
        • 158 Posts
        Thats perfect!!

        Could you explain what your code example does just so I can understand?

        It even randomizes 100% on each refresh!!

        Brett
          • 4172
          • 5,888 Posts
          Ok I can try it:

          This Ditto-call
          [[Ditto? &parents=`3` &display=`12` &tpl=`@CODE[+id+],`]]

          gets the first 12 documents by default order (createdon) and uses as Template
          [+id+],

          so it generates a commaseperated list eg. 213,234,456,456,78,

          (the last unused comma is cleaned by ditto)

          now I have a documentlist I can put to the Ditto-parameter &documents.

          The Ditto call
          [!Ditto? &documents=`......` &display=`all` &randomize=`1` &tpl=`workpreview`!]

          now randomizes these documents and displays them with your tpl.

          Thats all.

          cheers Bruno
            -------------------------------

            you can buy me a beer, if you like MIGX

            http://webcmsolutions.de/migx.html

            Thanks!
            • 22969
            • 158 Posts
            Hey Bruno,

            Thanks for that, makes sense to me now much appreciated!

            Just one last question now I come to think of it, I know we have the sort by "createdon" option, but is there way way I can get ditto to display them as the order they are in the "manager", they are listed in a different order then what they were created in you see, I guess im asking can the order be user defined?? As I want to be able to reorder the work in the manager.

            Sorry last question im sure smiley

            Cheers

            Brett
              • 4172
              • 5,888 Posts
              the ’normal’ order in manager is menuindex.

              you can use &orderBy=`menuindex ASC` or &orderBy=`menuindex DESC`

              so your call have to look like this for example:

              [!Ditto? &documents=`[[Ditto? &parents=`3`&orderBy=`menuindex DESC` &display=`12` &tpl=`@CODE[+id+],`]]` &display=`all` &randomize=`1` &tpl=`workpreview`!]
                -------------------------------

                you can buy me a beer, if you like MIGX

                http://webcmsolutions.de/migx.html

                Thanks!
                • 22969
                • 158 Posts
                Doh! Crikey thats quite obvious, but i did try looking for a way to do it like that but couldn’t find any documentation on it!

                Thanks again Bruno smiley

                Brett
                  • 22969
                  • 158 Posts
                  Bruno,

                  Sorry to bring this back up, but I just changed the order in the manager of the projects using "Doc Manager" problem is its not taking the new order to the front end of the site using menuindex, do you know how I can fix this?

                  Cheers
                    • 22969
                    • 158 Posts
                    Sorry ignore me was a cache issue