Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If You want to Display top level categories and subcategories U can do Like This..</p> <pre><code>&lt;?php $_helper = Mage::helper('catalog/category') ?&gt; &lt;?php $_categories = $_helper-&gt;getStoreCategories() ?&gt; &lt;?php $currentCategory = Mage::registry('current_category') ?&gt; &lt;?php if (count($_categories) &gt; 0): ?&gt; &lt;ul&gt; &lt;?php foreach($_categories as $_category): ?&gt; &lt;li&gt; &lt;a href="&lt;?php echo $_helper-&gt;getCategoryUrl($_category) ?&gt;"&gt; &lt;?php echo $_category-&gt;getName() ?&gt; &lt;/a&gt; &lt;?php $_category = Mage::getModel('catalog/category')-&gt;load($_category-&gt;getId()) ?&gt; &lt;?php $_subcategories = $_category-&gt;getChildrenCategories() ?&gt; &lt;?php if (count($_subcategories) &gt; 0): ?&gt; &lt;ul&gt; &lt;?php foreach($_subcategories as $_subcategory): ?&gt; &lt;li&gt; &lt;a href="&lt;?php echo $_helper-&gt;getCategoryUrl($_subcategory) ?&gt;"&gt; &lt;?php echo $_subcategory-&gt;getName() ?&gt; &lt;/a&gt; &lt;/li&gt; &lt;?php endforeach; ?&gt; &lt;/ul&gt; &lt;?php endif; ?&gt; &lt;/li&gt; &lt;?php endforeach; ?&gt; &lt;/ul&gt; &lt;?php endif; ?&gt; </code></pre> <p>For Displaying Top Level Categories and Current Categories SubCategories you can Do like ....</p> <pre><code>&lt;?php $_helper = Mage::helper('catalog/category') ?&gt; &lt;?php $_categories = $_helper-&gt;getStoreCategories() ?&gt; &lt;?php $currentCategory = Mage::registry('current_category') ?&gt; &lt;?php if (count($_categories) &gt; 0): ?&gt; &lt;ul&gt; &lt;?php foreach($_categories as $_category): ?&gt; &lt;li&gt; &lt;a href="&lt;?php echo $_helper-&gt;getCategoryUrl($_category) ?&gt;"&gt; &lt;?php echo $_category-&gt;getName() ?&gt; &lt;/a&gt; &lt;?php if ($currentCategory &amp;&amp; $currentCategory-&gt;getId() == $_category-&gt;getId()): ?&gt; &lt;?php $_category = Mage::getModel('catalog/category')-&gt;load($_category-&gt;getId()) ?&gt; &lt;?php $_subcategories = $_category-&gt;getChildrenCategories() ?&gt; &lt;?php if (count($_subcategories) &gt; 0): ?&gt; &lt;ul&gt; &lt;?php foreach($_subcategories as $_subcategory): ?&gt; &lt;li&gt; &lt;a href="&lt;?php echo $_helper-&gt;getCategoryUrl($_subcategory) ?&gt;"&gt; &lt;?php echo $_subcategory-&gt;getName() ?&gt; &lt;/a&gt; &lt;/li&gt; &lt;?php endforeach; ?&gt; &lt;/ul&gt; &lt;?php endif; ?&gt; &lt;?php endif; ?&gt; &lt;/li&gt; &lt;?php endforeach; ?&gt; &lt;/ul&gt; &lt;?php endif; ?&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload