We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 1330
    • 79 Posts
    Hello everyone,
    is there a way to have a dynamic home page that changes between a set depending on the day of week?
      • 25969
      • 118 Posts
      A snippet like so should do the trick, call it "HomeToday" -
      <?php
      
      // Load up with Doc IDs relating to days, starting with Monday
      $home = array(2,3,4,5,6,7);
      
      // Push them on based on date()'s value
      $modx->sendForward($home[date(N)-1]);
      
      ?>

      Then call it at the top of the MODx home page.
      [!HomeToday!]
        • 1330
        • 79 Posts
        can you show me an example? Trying to understand how it would work.
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          Create 7 documents, one for each day.

          Create a new snippet with the code as shown above (edit the array to have the actual IDs of your documents). Name it HomeToday.

          As the content for your site_start document (as set in the Configuration; it’s 1 by default) put the snippet tags [[HomeToday]].

          That should do the job.

            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
            • 15083
            • 697 Posts
            Do you need to change the entire page each day? Or just part of it each day?
            If you need to change the entire page, you can do the above, if you only need to change a portion of the page you can:

            Write a snippet (php snippet) that determines the day, and outputs a chunk (html chunk) based on what day it is? Are you changin much each day?
              • 7231
              • 4,205 Posts
              $home[date(N)-1]
              How does this work?

              Never mind, the manual helped rolleyes

              date — Format a local time/date
              Description
              string date ( string $format [, int $timestamp ] )

              Returns a string formatted according to the given format string using the given integer timestamp or the current time if no timestamp is given. In other words, timestamp is optional and defaults to the value of time().

              About the N:
              N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) 1 (for Monday) through 7 (for Sunday)

              So I guess that this means that the above snippet example should only work in php5.
                [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&#39;t know what it is.
                Do you, Mr. Jones? - [bob dylan]
                • 1330
                • 79 Posts
                Well I’m doing a movie theaters website, I have it up and running but wanted to see how hard to would be to have it change between the 3 showtime blocks, eg. Monday-Thursday, Friday, Saturday & Sunday. Because they change showtimes but I wanted to guest to be brought to that days show time on that day, they can navigate to the other STs by clicking the menu but they wanted to have the least amount of work to do as possible.
                (Though I should have charged 2x for the amount of work I had to do to get it the way they wanted)