|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
cwebnet Smarty n00b
Joined: 23 Dec 2009 Posts: 3
|
Posted: Wed Dec 23, 2009 12:41 pm Post subject: Seasons dates logic |
|
|
Hi all,
i need your help to do a logic of Seasons dates, i have done something but seems not work correctly, I will appreciate all your help, thanks.
Code: | {assign var="date_now" value=$smarty.now|date_format:"%Y/%m/%d"}
{assign var="date_year" value=$smarty.now|date_format:"%Y"}
{assign var="default" value="default"}
{assign var="spring" value="$date_year/03/21"}
{assign var="summer" value="$date_year/06/21"}
{assign var="fall" value="$date_year/09/21"}
{assign var="winter" value="$date_year/12/21"}
{if $spring >= $date_now} -> Spring
{elseif $summer >= $date_now} -> Summer
{elseif $fall >= $date_now} -> Fall
{elseif $winter >= $date_now} -> Winter
{else}
{$default}
{/if} | [/code] |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Wed Dec 23, 2009 4:02 pm Post subject: |
|
|
Why not make a plugin and do this in PHP? Then the template would just be:
{show_season} |
|
Back to top |
|
cwebnet Smarty n00b
Joined: 23 Dec 2009 Posts: 3
|
Posted: Wed Dec 23, 2009 4:22 pm Post subject: |
|
|
mohrt wrote: | Why not make a plugin and do this in PHP? Then the template would just be:
{show_season} |
Thanks yup i did this in php yes, but i want in smarty , so I did this and seems to work, what is your opinion?
Code: | {assign var="season" value='z'|date}
{if $season <= 164 and $season >= 70}
Spring
{else}
{if $season <= 295 and $season >= 165}
Summer
{else}
{if $season <= 327 and $season >= 296}
Autumn
{else}
Winter
{/if}
{/if}
{/if} |
|
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Wed Dec 23, 2009 4:27 pm Post subject: |
|
|
If it works for you. I'd rather put all that stuff in a plugin. |
|
Back to top |
|
cwebnet Smarty n00b
Joined: 23 Dec 2009 Posts: 3
|
Posted: Wed Dec 23, 2009 4:38 pm Post subject: |
|
|
mohrt wrote: | If it works for you. I'd rather put all that stuff in a plugin. |
It's an idea yes, thanks for your answers! |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|