I am trying to find a simple way to split the following array into a number of columns, instead of one very long list. I don't want to use tables to chunk it up, so I need to split into a variable number of UL's. Magento seems to be very picky and I have not been able accomplish this. I appreciate any suggestions.
<div class="category-grid">
<?php $_columnCount; ?>
<ul>
<?php if($i++%$_columnCount==0): ?>
<?php foreach ($this->getCurrentCategory()->getChildrenCategories() as $_subcat): ?>
<li class="item<?php if(($i-1)%$_columnCount==0): ?> first<?php elseif($i%$_columnCount==0):?> last<?php endif; ?>">
<a href="<?php echo $_subcat->getUrl() ?>">
<div class="category-data"><?php echo Mage::helper('catalog/output')->categoryAttribute($_subcat, $_subcat->getName()) ?></div>
</a>
</li>
<?php endforeach ?>
</ul>