View Full Version : Smarty Concatenation

09-03-2007, 01:17 PM

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}
{foreach from=$'aKit_'|cat:$key key=key2 item=kit}

but this is not working.

I would appreciate any help with this.

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}
{foreach from=$aSizes key=size_key item=size}