https://github.com/bloke/smd_countdown
Textpattern CMS plugin for counting down to an event
https://github.com/bloke/smd_countdown
textpattern textpattern-plugin
Last synced: 3 months ago
JSON representation
Textpattern CMS plugin for counting down to an event
- Host: GitHub
- URL: https://github.com/bloke/smd_countdown
- Owner: Bloke
- License: gpl-2.0
- Created: 2014-10-29T10:29:34.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2019-10-18T13:45:31.000Z (over 5 years ago)
- Last Synced: 2025-01-10T01:54:42.356Z (5 months ago)
- Topics: textpattern, textpattern-plugin
- Language: PHP
- Size: 17.6 KB
- Stars: 1
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.textile
- Changelog: CHANGELOG.textile
- License: LICENSE
Awesome Lists containing this project
README
h1. smd_countdown
h2. Features
* Countdown to either:
** article posted, expired, modified time.
** any time given in any article field.
** any arbitrary time given as an English date.
* Supports @@ so you can take action when the time is reached.
* Display number of years, months, weeks, days, hours, minutes, seconds as either:
** an absolute number (10 days to go).
** a date-based number (1 week 3 days to go).h2(#install). Installation / Uninstallation
Download the plugin from either "GitHub":https://github.com/Bloke/smd_countdown/releases, the "software page":https://stefdawson.com/smd_countdown or "textpattern.org":https://textpattern.org/plugins/1115/smd_countdown, paste the code into the Textpattern _Admin->Plugins_ panel, install and enable the plugin. Visit the "forum thread":https://forum.textpattern.com/viewtopic.php?id=31494 for more info or to report on the success or otherwise of the plugin.
To uninstall, delete from the _Admin->Plugins_ panel.
h2. Usage
h3. @@
Place this tag in any article or page to count down to a specific date/time. If you wish to use it to count down to a date in the given article you must ensure it's used in an article context (the plugin will complain if you don't). Use the @to@ attribute to configure the destination date. Examples:
In a Page:
bc.
It's Christmas day!In an article / article Form:
bc.
Posted date has arrived.Event hasn't started yet.
Or:
bc.
Too late, you missed it :-(There's still time to get to the show...
Or:
bc.
The date in custom field #1 (called my_date) has been reachedh3. @@
If you wish to show visitors how much time they have left before the destination arrives, use this tag to display various time elements. The following attributes configure what you wish to show:
h4. Attributes
* *display* the item(s) you wish to display. Can use one or more (comma-separated) from the following:
** *year* (or year_total) the number of years until the event.
** *month* the number of calendar months until the event, maximum 12[1].
** *month_total* the absolute number of months until the event[1].
** *week* the number of calendar weeks until the event, maximum 52[2].
** *week_total* the absolute number of weeks until the event[2].
** *day* the number of calendar days until the event, maximum 7.
** *day_total* the absolute number of days until the event.
** *hour* the number of day-based hours until the event, maximum 24.
** *hour_total* the absolute number of hours until the event.
** *minute* the number of hour-based minutes until the event, maximum 60.
** *minute_total* the absolute number of minutes until the event.
** *second* the number of minute-based seconds until the event, maximum 60.
** *second_total* the absolute number of seconds until the event.
** *destination* the UNIX timestamp of the destination.
** *difference* the UNIX timestamp difference between now and the destination (may be negative if the destination has passed).
** *abs_difference* the UNIX timestamp difference between now and the destination irrespective of whether the date has passed or not.
* *show_zeros* if you wish to hide leading items that have zero months, weeks, days, etc, set this to 0. Default: 1.
* *pad* pad the numerical output with some text. Specify up to two comma-separated values here. The first is the total width in characters of the string you wish to display. The second is the text with which you wish to pad the numbers. Default: @2, 0@ (i.e. pad to a width of two characters, using zeros if necessary).
* *label* up to two values with which you can label the given display item(s). If you specify two values, the first is what to use for singular numbers (e.g. 1 *hour*), the second is the plural (e.g. 3 *hours*). Note that using the @singular, plural@ form in this attribute does not usually make sense when @display@ is a list of items. Default: unset.
* *labeltag* HTML tag, without brackets, to wrap the label with. Default: unset.
* *labelafter* set to 1 if you wish the label to be appended to the displayed item(s). Default: 0 (i.e. prepend).
* *labelspacer* text to put before/after the label. Very useful if @labelafter="1"@ and you wish to put a space between the number and the label. Default: unset.
* *wraptag* HTML tag, without brackets, to wrap the displayed items with. Default: unset.
* *class* CSS class name to apply to the wraptag. Default: @smd_time_info@.
* *break* HTML tag, (without brackets) or other delimiter to wrap / put between each display item. Default: unset.fn1. Months may get a little distorted over time because a month is assumed to be 30 days.
fn2. Weeks may get a little distorted over time because some years have 53 weeks.
h2. Examples
h3(#eg1). Example 1: Countdown to posted item
The tag defaults to the posted date of the current article.
bc. The party
has arrived. Get your raving trousers on!is
days away: buy a shirt.The above will always show ‘days away', even when the last day is reached. To improve this, you can do:
bc. is
away: buy a shirt.h3(#eg2). Example 2: Displaying multiple items
bc.
Time remaining:
Add @show_zeros="0"@ if you wish to remove any leading zero items as the date draws near. Note that it only removes the most significant ‘zero' items. For example, if you are just over 1 week away from an event:
bc.
Might display: @01:00:05:00:19@ (1 week, 0 days, 5 hours, 0 minutes, 19 seconds). But at the same time next day it would show: @06:05:00:19@ (6 days, 5 hours, 0 minutes, 19 seconds).
h3(#eg3). Example 3: Using other fields
A question mark before the name of the field will use the date or timestamp given in that field.
bc.
Event kicks off in:
The @event_date@ custom field in this case must contain either:
* an English date such as @25 Aug 2014 12:00:00@
* a UNIX timestamp valueh3(#eg4). Example 4: Chaining timers
Starting to go a little crazy now...
bc.
Time's up!
You missed this animal by
You have
left to enjoy this animal.
arrives in seconds.
Very useful for competition articles or events. Note that this only works if the _publish expired articles_ setting is switched on in Advanced Prefs.
h3(#eg5). Example 5: There is no example 5...
... but as food for further study you could use the output from smd_countdown to seed the start of a JavaScript or flash-based timer which updated a real-time clock counting down to your event.
h2(#author). Author / credits
"Stef Dawson":https://stefdawson.com/contact. A more flexible version of glx_countdown.