1

My code:

    <div class="grid_3 {if $smarty.foreach.aussen.iteration ?????} alpha {/if}
{if $smarty.foreach.aussen.iteration % 4 == 0} omega {/if} "></div>

This works fine:

{if $smarty.foreach.aussen.iteration % 4 == 0} omega {/if} 

But I need a formula for this steps 1, 5, 9, 13, 18, 23:

{if $smarty.foreach.aussen.iteration ?????} alpha {/if}
Paulo Freitas
  • 13,194
  • 14
  • 74
  • 96
giller
  • 35
  • 5
  • 1
    I didn't get why the inverse formula you're expecting 1, 5, 9, 13, 18 and 23... Shouldn't it be 1, 5, 9, 13, 17 and 21? Please, try to explain it more thoroughly. :) – Paulo Freitas Nov 17 '13 at 08:32

2 Answers2

1

Well, I'm just guessing here, since your question left some doubts... If I understood it correctly you're trying to achieve that:

    <div class="grid_3 {if $smarty.foreach.aussen.iteration % 4 == 1}alpha{/if}
{if $smarty.foreach.aussen.iteration % 4 == 0}omega{/if}"></div>
Paulo Freitas
  • 13,194
  • 14
  • 74
  • 96
  • sorry for me bad english – giller Nov 17 '13 at 09:59
  • @giller Well, `iteration % 4 == 0` will match on every iteration divisible by 4. On other hand, `iteration % 4 == 1` will match every time the remainder of division of iteration by 4 is 1, which means that it'll match every subsequent iteration of the prior formula. Did you got it? :) – Paulo Freitas Nov 17 '13 at 10:41
0

If it's just 6 values you need special handing for (1, 5, 9, 13, 18, 23), then don't bother with creating a formula:

{foreach name = "aussen" from = $some_array}
  <div class="grid_3 {if $smarty.foreach.aussen.iteration|in_array:array(1, 5, 9, 13, 18, 23)} alpha {/if}
  {if $smarty.foreach.aussen.iteration % 4 == 0} omega {/if}"></div>
{/foreach} 

Smarty 3, I'm not sure if this works in Smarty2, but even if it doesn't, with very small adjustments it should

periklis
  • 10,102
  • 6
  • 60
  • 68