m3w Posted October 21, 2013 Share Posted October 21, 2013 Hello, i need to add a php function in my footer.tpl to show a div after a specific date. For example, the div called "topbar" should appear after the date 21 Octobre 12:00:00 This the php code: if (time() >= strtotime('October 21, 2013 12:00:00 GMT')) { echo "<div class="topbar">my message</div>"; } I've read that with smarty you can't paste the code inside a tpl, and the function {php} is deprecate, so how can i figured out? Any help would be appreciated Thanks Link to comment Share on other sites More sharing options...
jgullstr Posted October 21, 2013 Share Posted October 21, 2013 Hello,try {if ($smarty.now >= strtotime('October 21, 2013 12:00:00 GMT'))} <div class="topbar">my message</div> {/if} Link to comment Share on other sites More sharing options...
vekia Posted October 21, 2013 Share Posted October 21, 2013 you can't use php code in smarty template files (tpl) so it's better to use smarty syntax exactly as jgullstr suggested above Link to comment Share on other sites More sharing options...
m3w Posted October 22, 2013 Author Share Posted October 22, 2013 Hello, try {if ($smarty.now >= strtotime('October 21, 2013 12:00:00 GMT'))} <div class="topbar">my message</div> {/if} Thanks, it doesn't give error, but how can i set local hour? I've tried but the div didn't show up Link to comment Share on other sites More sharing options...
m3w Posted October 22, 2013 Author Share Posted October 22, 2013 Hello, try {if ($smarty.now >= strtotime('October 21, 2013 12:00:00 GMT'))} <div class="topbar">my message</div> {/if} i've tried this: {if ($smarty.now|date_format:"%B %e, %Y %H:%M:%S" >= strtotime('October 21, 2013 12:00:00 GMT'))} but seems wrong 'cause the div didn't show up... any advice? Link to comment Share on other sites More sharing options...
jgullstr Posted October 22, 2013 Share Posted October 22, 2013 I'm not certain I understand what you're trying to do. You shouldn't use any date formatting in the condition. Link to comment Share on other sites More sharing options...
m3w Posted October 22, 2013 Author Share Posted October 22, 2013 I'm not certain I understand what you're trying to do. You shouldn't use any date formatting in the condition. If i use this code: {if ($smarty.now >= strtotime('October 21, 2013 12:00:00 GMT'))} <div class="topbar">my message</div> {/if} the div don't show up, so i thought it was a problem of the date format. I need that the div topbar be visibile after 21th october and be hidden again on the 28 october. Any ideas? Thanks Link to comment Share on other sites More sharing options...
m3w Posted October 22, 2013 Author Share Posted October 22, 2013 Ok, i've solved like this: {if (strtotime('October 22, 2013 13:28:00 GMT') <= $smarty.now && strtotime('October 28, 2013 13:35:00 GMT') >= $smarty.now) } 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