We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 6316
    • 92 Posts
    I want to add a "picture of the day" to the main page of my site, but it’s essential for me and staff to automatize the process of uploading a new picture + updating the archive of the POTDs. Could you please recommend any solutions which could simplify such process? I haven’t managed to find anything on the forum, nor in MODx resources.
    Thanks.
      • 10226
      • 412 Posts
      I have a slideshow on my main page, it pulls a few random images with ditto. If you have A LOT of pictures a random approach would probably be fine.

      Here is my theory;

      Every hit calls a pre-load script that will pull a random image. The script will ’>’ put the random image into a server side ’cookie’ named ’potd’ along with a timestamp. A simple if / else / then with phx will then manage the potd. After the timestamp expires a new image will be inserted. This script could be easily extended to keep a history of so many days to ensure the same image is not displayed within so many days...

      If I could code, I could probably do that in ten minutes but that is a bit beyond me. I could do it in bash for sure, but not in modx!

      Good Luck!
        • 7231
        • 4,205 Posts
        I like the method proposed by ganeshXL, this would allow to prepare things ahead of time. However what happens if there is no image for a specific day? Is that what would go in the ’else // do something else...’ section?
          [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

          Something is happening here, but you don't know what it is.
          Do you, Mr. Jones? - [bob dylan]