movieprodw
asked on
PHP Query
Hello,
I have the following query and I would like it so that if there is a sub category then the parent category is not a link.
My ultimate goal is to make an accordion menu with this.
I have the following query and I would like it so that if there is a sub category then the parent category is not a link.
My ultimate goal is to make an accordion menu with this.
<?php foreach ($this->getStoreCategories() as $_category): ?>
<li>
<a href="<?php echo $this->getCategoryUrl($_category) ?>"><?php echo $this->htmlEscape($_category->getName()) ?></a>
<?php
$_catid=$_category->getId();
$category = Mage::getModel('catalog/category')->load($_catid);
$subcategory = $category->getAllChildren(true);
array_shift($subcategory);
if($subcategory!=null)
{?>
<ul>
<?php
foreach ($subcategory as $sub)
{
$sub1 = Mage::getModel('catalog/category')->load( $sub);
?>
<li><a href="<?php echo $sub1->getUrl();?>"><span>
<?php echo $sub1->getName(); ?>
</span></a></li>
<?php } ?>
</ul>
<?php }?>
</li>
<?php endforeach ?>
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
You are welcome - thanks for the points.
ASKER
Continued
https://www.experts-exchange.com/questions/28185076/PHP-query.html