I have a table of items. But it's over 25 items. What is needed is that the first 25 items will be outputted in a page. then the remaining items will be outputted to another page. That would only be seen when you print the html file.
I'm using smarty template in this. I'm using
.page {
width: 745px;
page-break-after: always;
}
to determine that there will be another page if every there is. Then I'm using this:
assign the limit:
{assign var='itemLimit' value=25}
count number of items:
{assign var='itemCount' value=$RO_ITEMS|@count}
count number of page to be looped:
{assign var='pageCount' value=$itemCount/$itemLimit}
count items after the first 25, or excess items:
{assign var='extraItems' value=$itemCount%$itemLimit}
assign the start and end:
{assign var='start' value=0}
{assign var='end' value=$itemLimit}
then I use {section} to loop items:
{section name='invoicePage' loop=$pageCount}
This is the foreach code I use to loop the items:
{foreach from=$ITEMS item=EACHITEM name=foo}
{if $smarty.foreach.foo.index >= $start and $smarty.foreach.foo.index < $end}
<tr>
<td>{$EACHITEM.ITEM_SKU}</td>
<td>{$EACHITEM.ITEM_TYPE}</td>
<td>{$EACHITEM.ITEM_BRAND}</td>
<td>{$EACHITEM.ITEM_COLOR}</td>
<td>{$EACHITEM.ITEM_SIZE}</td>
<td>{$EACHITEM.ITEM_QTY}</td>
</tr>
{/if}
{/foreach}
and at the end of everything needed to be looped, this is the code:
{$start = $start + $itemLimit}
{$end = $end + $itemLimit}
{/section}
Somehow, it's working that it's printing 25 items. But that is that.The other items after 25 are not outputted. Can anyone tell me what's wrong with this code? Thanks and regards.