|
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 |
electr0n Smarty Rookie
Joined: 26 Mar 2004 Posts: 32 Location: Germany
|
Posted: Fri Jun 04, 2004 7:06 pm Post subject: Switch? |
|
|
I would like to use something like a switch construct in Smarty. I could also use many many else-ifs, but switch would be a better and faster solution.
Code: | {switch condition=$var / 4}
{case match=1}
first case
{/case}
{case match=2}
second case
{/case}
{/switch} |
cheers, |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Fri Jun 04, 2004 7:15 pm Post subject: |
|
|
messju has provided at least two different example plugins at different times for doing switch -- try searching the forums. Feel free to post the threads here if you can find 'em |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Fri Jun 04, 2004 7:17 pm Post subject: |
|
|
You might as well throw a {break} in there too
This has been discussed before. I think the reasons it was never added:
* only an alternate to what can already be done with if/else
* would be used very infrequently (this is a template after all, not a program)
* yet another template construct to support and document |
|
Back to top |
|
electr0n Smarty Rookie
Joined: 26 Mar 2004 Posts: 32 Location: Germany
|
Posted: Fri Jun 04, 2004 7:26 pm Post subject: |
|
|
Ok, then sorry for that. But the search hasn't found anything
Probably I'll write something at my own and poste it here |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
|
Back to top |
|
electr0n Smarty Rookie
Joined: 26 Mar 2004 Posts: 32 Location: Germany
|
Posted: Fri Jun 04, 2004 7:32 pm Post subject: |
|
|
hehe, thx for that |
|
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
|