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

    Does anyone know how to achieve a random quote of the day with getresources or a similar snipped in MODX 2? The ideal solution will be to have the snippet read random paragraphs from a document or a file on the server.

    Thanks for your help
      A MODx Fanatic
      • 19369
      • 1,098 Posts
      Did not check, but maybe...this?
      http://modxcms.com/forums/index.php?topic=47341.0
        • 3749
        • 24,544 Posts
        getResources will do easily it if each quotation is a separate document, but that’s fairly wasteful.

        If you’re interested in writing your own, you might take a look at the EZfaq snippet, which parses a single document with Q: and A: prefixes for each part. You could easily use Q: for the quotation and A: for the author and select one at random with array_rand($docArray) and return it (after removing the extraneous code from the snippet).

        There’s also a snippet or two on the forums that does random quotations, but I believe that they all require each quotation to be a separate document, like getResources.
          Did I help you? Buy me a beer
          Get my Book: MODX:The Official Guide
          MODX info for everyone: http://bobsguides.com/modx.html
          My MODX Extras
          Bob's Guides is now hosted at A2 MODX Hosting
          • 30585
          • 833 Posts
          Quote from: BobRay at Sep 28, 2010, 11:37 PM

          getResources will do easily it if each quotation is a separate document, but that’s fairly wasteful.

          If you’re interested in writing your own, you might take a look at the EZfaq snippet, which parses a single document with Q: and A: prefixes for each part. You could easily use Q: for the quotation and A: for the author and select one at random with array_rand($docArray) and return it (after removing the extraneous code from the snippet).

          There’s also a snippet or two on the forums that does random quotations, but I believe that they all require each quotation to be a separate document, like getResources.

          That’s an excellent suggestion. Thanks both for your help!
            A MODx Fanatic