I'm creating a layout override for the category layout where I need to list the articles in a 2 column table:
+-----------+------------+
| | |
| item 1 | item 2 |
| | |
+-----------+------------+
| | |
| item 3 | item 4 |
| | |
+-----------+------------+
...etc...
but the articles are showing up duplicated:
+-----------+------------+
| | |
| item 1 | item 1 |
| | |
+-----------+------------+
| | |
| item 2 | item 2 |
| | |
+-----------+------------+
...etc...
I'm not sure how to increment the item# in the loop to make it show 2 items per row. here is the code I'm dealing with:
<?php if (!empty($this->intro_items)) : ?>
<table cellpadding="0" cellspacing="0" width="600" border="0" style="width: 580px !important;">
<?php foreach ($this->intro_items as $key => &$item) : ?>
<?php
$key= ($key-$leadingcount)+1;
$rowcount=( ((int)$key-1) % (int) $this->columns) +1;
$row = $counter / $this->columns ;
if ($rowcount==1) : ?>
<?php endif; ?>
<tr>
<td class="item column-<?php echo $rowcount;?><?php echo $item->state == 0 ? ' system-unpublished' : null; ?>">
<?php
$this->item = &$item;
echo $this->loadTemplate('item');
?>
</td>
<td width="20"> </td>
<td class="item column-<?php echo $rowcount;?><?php echo $item->state == 0 ? ' system-unpublished' : null; ?>">
<?php
$this->item = &$item;
echo $this->loadTemplate('item');
?>
</td>
</tr>
<?php if (($rowcount == $this->columns) or ($counter ==$introcount)): ?>
<?php endif; ?>
<?php endforeach; ?>
</table>
<?php endif; ?>