Link to home
Create AccountLog in
Avatar of movieprodw
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.

        <?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 ?> 

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of movieprodw
movieprodw

ASKER

You are welcome - thanks for the points.