Add a countdown widget to a page
- Kirk Mayo (Nickname: textagroup) email@example.com
- SilverStripe 3.1
Adds a countdown widget to a SilverStripe page widget
composer require "textagroup/countdown"
To setup a countdown timer the first thing to do is to apply the CoundownWidgetExtension to the page object.
This can be setup in the config yml file as per the example below which will add it to all pages
Page: extensions: - CountdownWidgetExtension
or alternatively you can apply the extension through some PHP code
This will add a countdown tab to the page in the CMS where you can set the Countdown date and the format of the countdown.
Then you need to setup where you want the countdown to appear by adding the the variable $Countdown to the relevant SilverStripe template.
<div class="main" role="main"> <div class="inner typography line"> $Countdown $Layout </div> </div>
This will add a div or span to your page with a Countdown timer you can then style the div or span with CSS via the relavant class which defaults to CountdownClock but can be amended via the CMS you can also amend the deafult element ID which defaults to clock
This module adds a countdown timer to a SilverStripe page and a date field to the cms section for the page which is used to set the countdown date
- Maybe more countdown clock styles