smarty count and foreach loop

I am trying to create multicolumns for a block but it doesn’t seem to be working, I have the following and it is simply adding the closing TR for each count rather then if it is divided by 5 as I have started in my IF statement.



Any ideas? Thanks



{if $items.companies}


{foreach from=$items.companies item=v key=k name=foo}


{if $smarty.foreach.foo.index % 5 == 0}
{/if}

{/foreach}


{if $items.companies|count < $items.count}


{$lang.view_all}


{/if}
{$v} - {$smarty.foreach.foo.index}

{/if}

Don’t you need to have your variables names in “”'s?

I.e.


{foreach from$items.companies item="v" name="foo"}




Just a thought…

% isn’t a valid operator. Use / instead



[URL]Search Results for "docsv2" | Smarty

Mod isn’t a valid operator??? Certainly it is in an if statement. Smarty simply takes the condition in its if statement and creates a PHP if statement.

I ended up getting this to work as I hoped. The code is as follows:



The biggest issue I could was the spacing, to explain:



WORKS - $smarty.foreach.foo.index%6

DOESN"T WORK - $smarty.foreach.foo.index % 6





{if $items.companies}



{foreach from=$items.companies item=v key=k name=foo}

{if $smarty.foreach.foo.index%6 == 0}
{/if}
{/foreach}

{$v}


{$lang.view_all}



{/if}




My only minor issue is the if statement puts in a TR after the first listing as that index value is 0. Any ideas how to change this? The rest work after that.



Thankyou

Wow, I find it hard to believe that the smarty parser cares whether there is whitespace between the operator and operands or not.

[quote]

Any ideas how to change this?

[/quote]


{if $smarty.foreach.foo.index && (($smarty.foreach.foo.index % 6) == 0) }

[quote name=‘tbirnseth’]Wow, I find it hard to believe that the smarty parser cares whether there is whitespace between the operator and operands or not.



{if $smarty.foreach.foo.index && (($smarty.foreach.foo.index % 6) == 0) }
[/QUOTE]





Thanks, this is close but it actually created 7 columns for the first row then 6 for the rest?