Skip to content

Instantly share code, notes, and snippets.

@xErik
Created September 2, 2016 15:36
Show Gist options
  • Save xErik/f72684fc66d614593e1bd355d200b9da to your computer and use it in GitHub Desktop.
Save xErik/f72684fc66d614593e1bd355d200b9da to your computer and use it in GitHub Desktop.
Create table with Smarty
<table id="frontpage_categories_new">
<tr>
{$cols=3}
{foreach $module_content as $module_data}
<td style="width:300px;">
<a href="{$module_data.categories_link}">
<img src="{$smarty.const.DIR_WS_IMAGES}categories/{$module_data.categories_image}">
{$module_data.categories_name} | {$smarty.foreach.foo.iteration neq 1 AND $smarty.foreach.foo.iteration is div by 3}
</a>
</td>
{if !$module_data@last AND $module_data@iteration is div by $cols}
</tr><tr>
{/if}
{if $module_data@last AND $module_data@iteration is not div by $cols}
<td colspan="{$cols-$module_data@iteration%$cols}"></td>
{/if}
{foreachelse}
<td colspan="{$cols}">No data</td>
{/foreach}
</tr>
</table>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment