Jump to content

[SOLVED] How to add a countdown inside main page above the "editorial" ?


Recommended Posts

Add the following to the top of index.tpl in your theme's directory:

{assign var='year' value=$smarty.now|date_format:'%Y'}
{assign var='christmas' value='12/25/'|cat:$year|strtotime}
{assign var='secondsTillChristmas' value=$christmas-$smarty.now}
{assign var='daysTillChristmas' value=$secondsTillChristmas/60/60/24}
{if $daysTillChristmas < 0}{math assign='daysTillChristmas' equation='365 + d' d=$daysTillChristmas}{/if}
{if $daysTillChristmas|ceil == 365}{assign var='daysTillChristmas' value=0}{/if}

{l s='There'} {if $daysTillChristmas|ceil == 1}{'is'}{else}{'are'}{/if} {$daysTillChristmas|ceil} {if $daysTillChristmas|ceil == 1}{'day'}{else}{'days'}{/if} {l s='till Christmas'}



This code should add "There are X days until Christmas" at the top of the centre column on the homepage. The code should work, though it may be possible to simplify it.

Link to comment
Share on other sites

I've modified my code above to wrap the text in a paragraph with id "daysTillChristmas". You can then add code like the following to your global.css:

p#daysTillChristmas
{
  text-align: center;
  color: blue;
  font-size: 12px;
  font-weight: bold
}



This will center the text, make it blue, 12px in size and bold.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...