...

View Full Version : Smarty Concatenation



daemonkin
09-03-2007, 01:17 PM
Hi,

I have a number of arrays assigned in PHP, all beginning with 'aKit_' followed by the type of kit. All kit types are assigned also as aKitTypes so I have all my kit types and kit type names assigned to the template.

I don't want to write out the same code for 14 different kit types and want to run a foreach through the kit types array and get the name out and then run through the array 'aKit_X' where X is the name of the array assigned and passed into the template.

I have tried 'cat' as in:

{foreach from=$aKitTypes key=key item=type}
<h3>{$type|capitalize}</h3>
{foreach from=$'aKit_'|cat:$key key=key2 item=kit}
{$key2}
{/foreach}
{/foreach}

but this is not working.

I would appreciate any help with this.

Edit:
This works but needs to be done for each type:

<h4>Kit Socks</h4><table class="kit_breakdown"><tr><th>Colour/Size: </th>{foreach from=$aSizes key=size_key item=size}<th class="size">{$size}</th>{/foreach}</tr>
{foreach from=$aKit_kit_socks key=key item=item}
<tr>
<td>{$item.description}</td>
{foreach from=$aSizes key=size_key item=size}
<td>{$item.$size}</td>
{/foreach}
</tr>
{/foreach}
</table>

D.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum