Override inner cols with inner rows Smarty columns
I have 3 columns inside a table and my information is being displayed
correctly. However, the information is being displayed horizontally in the
smarty template.
1 2 3
4 5 6
7 8 9
How can I display it vertically instead?
Like this:
1 4 7
2 5 8
3 6 9
What I need is a solution, Something similar to this: {html_table
inner=rows cols=3 loop=$array}
{* Categories *}
{if !empty($categs)}
{if !empty($category.ID)}
<h3>{l}Books{/l}</h3>
{/if}
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
{foreach from=$categs item=cat name=categs}
{if ($smarty.foreach.categs.iteration mod $cats_per_col eq 1 and
$cats_per_col gt 1) or $smarty.foreach.categs.first}<td>{/if}
<h2 {if !empty($category.ID)}class="blocktext"{/if}><a href="{if
!empty($cat.URL)}
{$cat.URL}{else}{$smarty.const.DOC_ROOT}/{$cat.CACHE_URL|escape}{/if}" {if
$cat.NEW_WINDOW eq 1}target="blank"{/if} title="{$cat.TITLE|escape}"
class="catHomeMain">{$cat.TITLE|escape} </a>{if
$smarty.const.CATS_COUNT}{if !empty($cat.URL)}{else} <span
class="catHomeCount">({$cat.COUNT})</span>{/if}{/if}</h2>
{* Display subcategories *}
{if !empty($cat.SUBCATS)}
{foreach from=$cat.SUBCATS item=scat name=scategs key=key}
{capture name="column"}{math equation="x % 3" x=$key}{/capture}
{if $smarty.capture.column == "0"}
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="177px">
<ul class="navcontainer"><li>
<a href="{if !empty($scat.URL)}{$scat.URL}{else}
{$smarty.const.DOC_ROOT}/{$scat.CACHE_URL|escape}{/if}" {if
$scat.NEW_WINDOW eq 1}target="blank"{/if}
title="{$scat.TITLE|escape}"
class="catHomeSub">{$scat.TITLE|escape}</a></li></ul>
</td>
{elseif $smarty.capture.column == "1"}
<td width="177px">
<ul class="navcontainer"><li>
<a href="{if !empty($scat.URL)}{$scat.URL}{else}
{$smarty.const.DOC_ROOT}/{$scat.CACHE_URL|escape}{/if}" {if
$scat.NEW_WINDOW eq 1}target="blank"{/if} title="{$scat.TITLE|escape}"
class="catHomeSub">{$scat.TITLE|escape}</a>
</li></ul>
</td>
{elseif $smarty.capture.column == "2"}
<td width="177px">
<ul class="navcontainer"><li>
<a href="{if !empty($scat.URL)}{$scat.URL}{else}
{$smarty.const.DOC_ROOT}/{$scat.CACHE_URL|escape}{/if}" {if
$scat.NEW_WINDOW eq 1}target="blank"{/if} title="{$scat.TITLE|escape}"
class="catHomeSub">{$scat.TITLE|escape}</a>
</li></ul>
</td>
</tr>
</table>
{/if}
{/foreach}
{if $smarty.capture.column != 2}
<!-- Close the table! -->
</tr></table>
{/if}
{/if}
{if ($smarty.foreach.categs.iteration mod $cats_per_col eq 0 and
$cats_per_col gt 1) or $smarty.foreach.categs.last}</td>{/if}
{/foreach}
</tr>
</table>
<div class="break" style="height:20px;"></div>
{/if}
No comments:
Post a Comment