I have a section of code which finds if there are subcategories of a category and if there is then it displays the subcategories in a list view.
I am trying to add in a function that says if the subcategories are over 1 then show a DIV and if not then do not show the DIV as it wont be showing any subcategories.
This is what I have so far but it doesn't seem to be working.
<?php
/* Load category by id */
$cat = Mage::registry('current_category');
/*Returns comma separated ids*/
$subcats = $cat->getChildren();
if (count($subcats) > 0): ?>
<div style="width:100%; height:auto; text-align:center; font-size:16px; color:#373737; padding:2px 0; margin-top:-5px; margin-bottom:3px; background:#f1f1f1;">Choose Your Category</div>
<?php endif;
foreach(explode(',',$subcats) as $subCatid)
{
$_category = Mage::getModel('catalog/category')->load($subCatid);
if($_category->getIsActive()) {
echo '<li><a href="'.$_category->getURL().'" title="View the products for the "'.$_category->getName().'" category">'.$_category->getName().'</a></li>';
/* Load category by id */
$sub_cat = Mage::getModel('catalog/category')->load($_category->getId());
}
}
?>