Jump to content

Add php function


m3w

Recommended Posts

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

 

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

 

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

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

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...