I'm having some issues displaying some nested array results in smarty... here's what I have:
$searchResults
- an array, where each row is a result set. No problem here.
$searchResults[$row][users][]
- this is the nested array I created. If users exist for this row of the search results, I want to display every user....
So, here we have my smarty code:
{section name=i loop=$searchResults}
{section name=j loop=$searchResults[i].users}
{$searchResults[i].users[j].firstName}
{/section}
{/section}
However, this doesn't seem to work out for me... it displays the users results in a crazy fashion in my table, instead of being inside the same <td></td>
where the section is placed inside.
UPDATE - Using For Each, with more code...
{section name=i loop=$searchResults}
<tr>
<td>{$searchResults[i].id}</td>
<td>
{if $searchResults[i].users}
{foreach from=$searchResults[i].users item=user}
{$user.firstName} {$user.lastName} <br>
{/foreach}
{/if}
</td>
</tr>
{/section}
This displays a table like this:
ID
ID
ID
Bob Boberton
John Appleton
Chris Cooley
Carl Agley
Cynthia Nobody
When it should be like this:
ID Bob Boberton
John Appleton
ID Chris Cooley
ID Carl Agley
Cynthia Nobody