Forums / Setup & design / If-then-elseif/case; Is there a better way in ez
Tristan Koen
Thursday 20 November 2003 2:09:01 am
I have a small control structure that I have written in the ez templating language that is incredibly cumbersome (see below). Can anyone suggest a better way to do this?All it is supposed to do is show an image of start (rating) for different values of user ratings.
--------------------------- {section show=$:item.Rating|gt(4.75)} <img src={"stars-5-0.gif"|ezimage} alt="Rating: {$:item.Rating}" border="0" /> {section-else} {section show=$:item.Rating|gt(4.25)} <img src={"stars-4-5.gif"|ezimage} alt="Rating: {$:item.Rating}" border="0" /> {section-else} {section show=$:item.Rating|gt(3.75)} <img src={"stars-4-0.gif"|ezimage} alt="Rating: {$:item.Rating}" border="0" /> {section-else} {section show=$:item.Rating|gt(3.25)} <img src={"stars-3-5.gif"|ezimage} alt="Rating: {$:item.Rating}" border="0" /> {section-else} {section show=$:item.Rating|gt(2.75)} <img src={"stars-3-0.gif"|ezimage} alt="Rating: {$:item.Rating}" border="0" /> {section-else} {section show=$:item.Rating|gt(2.25)} <img src={"stars-2-5.gif"|ezimage} alt="Rating: {$:item.Rating}" border="0" /> {section-else} {section show=$:item.Rating|gt(1.75)} <img src={"stars-2-0.gif"|ezimage} alt="Rating: {$:item.Rating}" border="0" /> {section-else} {section show=$:item.Rating|gt(1.25)} <img src={"stars-1-5.gif"|ezimage} alt="Rating: {$:item.Rating}" border="0" /> {section-else} {section show=$:item.Rating|gt(0.75)} <img src={"stars-1-0.gif"|ezimage} alt="Rating: {$:item.Rating}" border="0" /> {section-else} <img src={"stars-0-0.gif"|ezimage} alt="Rating: {$:item.Rating}" border="0" /> {/section} {/section} {/section} {/section} {/section} {/section} {/section} {/section}{/section}
Tore Skobba
Thursday 20 November 2003 2:30:14 am
Hmm switch/case ?
Like {switch match=$:item.Rating} {case match=gt(1.25)} do some stuff {/case} {case match=gt(2.35)} do some stuff {/case}{/switch}
Thursday 20 November 2003 4:15:52 am
Yes... thats exactly what I was looking for. I must have missed it in the docs.Thanks very much for the help.