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
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!
-
☆ 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
Oh, a few other countdown options if you need more ideas:
http://www.tripwiremagazine.com/2012/05/jquery-countdown-scripts.html
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.
-
☆ 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().
countDown Snippet usage
[[countDown? ¤tChunk=`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.