troubleshooting Question

PHP Query

Avatar of movieprodw
movieprodw asked on
PHP
3 Comments1 Solution200 ViewsLast Modified:
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 ?> 
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 3 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros