Page 1 of 1

[SOLVED]Use {current_date} to show picture

Posted: Tue Oct 25, 2011 7:32 pm
by Recon
Hi,

I am trying to use {current_date} to change picture on website. I want to show different picture on every week. I have tried to use this:

Code: Select all

{$week = current_date format="%W"}
{if $week eq 43}
Some picture <img tag>
{elseif $week eq 44}
Some picture <img tag>
{elseif $week eq 45}
Some picture <img tag>
{/if} 
but obviously I can't write smarty, so this doesnt work ;D Why it's not working?

-R

Re: Use {current_date} to show picture

Posted: Tue Oct 25, 2011 8:06 pm
by RonnyK
What if you just call the image like

image($week}.jpg

That way, there is a single call, and you can just create images called image01.jpg, image02.jpg etc....

Ronnyy

Re: Use {current_date} to show picture

Posted: Tue Oct 25, 2011 8:48 pm
by uniqu3
Use this and it will work:

Code: Select all

{assign var='week' value=$smarty.now|date_format:"%W"}
But as RonnyK said, using it as image name would probably make it easier to handle then having a bunch of if's for a small image.

Re: Use {current_date} to show picture

Posted: Wed Oct 26, 2011 7:47 am
by Recon
Works perfectly!!! Thank you guys! :-*

-R