We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 40313
    • 8 Posts
    I am looking for a "20 hours left until the event!" type of countdown timer for Revolution. I didn't see a plugin like this after some searching - has anyone seen one?

    Thanks,

    David
      • 32316
      • 387 Posts
      I haven't seen a plugin but I have incorporated "jQuery Countdown" a jquery based one into a revo site - http://railstotrails5k.com though currently it has finished its countdown!

      check out this url:
      http://keith-wood.name/countdown.html

      It was pretty simple to do. If you have trouble pm me and I can research how I did it - I don't have time to look right now.
        • 40313
        • 8 Posts
        Ok, I guess I need to get out of the "everything needs to be a plugin" Wordpress mindset and just use java-style stuff inside ModX pages.

        Thanks for the suggestions!
          • 1343 ☆ A M B ☆
          • 2,213 Posts
          The biggest secret to learning MODX is unlearning everything you learned with Wordpress, well except how to do html/css/js, but that's standard wink

          Oh, a few other countdown options if you need more ideas: http://www.tripwiremagazine.com/2012/05/jquery-countdown-scripts.html
            Patrick | Server Wrangler
            About Me: Website | Tweets |  MODX Hosting
            • 32316
            • 387 Posts
            being picky it is not
            java-style stuff
            but javascript stuff

            and it needs to be javascript since a countdown counter runs in the browser

            and one of the strengths of MODX is the ease with which you can add php or javascript to a page
              • 36762
              • 45 Posts
              I would like to see a snippet for this that includes the (Ajax) ability to display one chunk of code during the countdown and another chunk when the countdown expired. Without the user having to refresh the browser.

              In addition it would be nice to have options for multiple repeating events so if you were doing something every Monday at 9:00am for one hour and every Wednesday at 10:00am for two hours the countdown timer would just run continuously flipping back and forth between the chunks automatically.


              This would be useful for embedding something like a Youtube playlist of live streams, because when not live streaming Youtube sends the viewer to nowhere. So it would be nice to hide that embed code until the stream is actually live.
                • 28042 ☆ A M B ☆
                • 24,524 Posts
                Every Javascript countdown I ever used had that expiration feature as part of its own code. Usually it's in the initializing code of the javascript. It's easy enough to have a snippet generate the desired initialization javascript and add it to the bottom of your template using regClientScript().
                  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
                  • 20413
                  • 2,877 Posts
                  "Basic Clock: Count down to a Specific Date or Time" http://www.sitepoint.com/build-javascript-clock-no-dependencies/
                    @hawproductions | http://mrhaw.com/

                    Infograph: MODX Advanced Install in 7 steps:
                    http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

                    Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
                    http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
                    • 4385
                    • 372 Posts
                    countDown Snippet usage
                    [[countDown? &currentChunk=`availableChunk`]]


                    availableChunk Chunk
                    Act now! Only [[+daysLeft]] days left.


                    countDown Snippet
                    <?php
                    $endDate = $modx->getOption('endDate',$scriptProperties,'20151225');
                    $expiredChunk = $modx->getOption('expiredChunk',$scriptProperties,'');
                    $currentChunk = $modx->getOption('currentChunk',$scriptProperties,'');
                    
                    $endYear = substr($endDate,0,4);
                    $endMonth = substr($endDate,4,2);
                    $endDay = substr($endDate,6,2);
                    
                    $hours_left = (mktime(0,0,0,$endMonth,$endDay,$endYear) - time())/3600;
                    $daysLeft = ceil($hours_left/24);
                    
                    $modx->setPlaceholder('hoursLeft',floor($hours_left));
                    $modx->setPlaceholder('daysLeft',$daysLeft);
                    
                    if ($daysLeft >= 0) {
                      $output = empty($currentChunk)? $daysLeft:$modx->getChunk($currentChunk);
                    } else {
                      $output = $modx->getChunk($expiredChunk);
                    }
                    return $output;
                    
                      DropboxUploader -- Upload files to a Dropbox account.
                      DIG -- Dynamic Image Generator
                      gus -- Google URL Shortener
                      makeQR -- Uses google chart api to make QR codes.
                      MODxTweeter -- Update your twitter status on publish.