alivok Posted July 8, 2010 Share Posted July 8, 2010 I would like to have a line like"it is 150...149....148 and etc. days till Christmas"What's the code and where should it be inserted, can you help me, guys ? Link to comment Share on other sites More sharing options...
rocky Posted July 9, 2010 Share Posted July 9, 2010 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 More sharing options...
alivok Posted July 9, 2010 Author Share Posted July 9, 2010 Wow, thanks, it works !How can I center it and change the text color and size ? Link to comment Share on other sites More sharing options...
rocky Posted July 9, 2010 Share Posted July 9, 2010 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 More sharing options...
alivok Posted July 9, 2010 Author Share Posted July 9, 2010 Thanks again ! Link to comment Share on other sites More sharing options...
rocky Posted July 9, 2010 Share Posted July 9, 2010 If your issue is resolved, please edit your first post and add [sOLVED] to the front of the title. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now