Brian Wigginton libB – Notes & Tutorials on Delicious Bytes of Technology

Magento Sidebar Categories

Posted on January 17, 2010

The following will display a list of categories in your store in your right sidebar.

Layout

Alter page.xml so that the default handle's right block contains the following:

<block type="catalog/navigation" name="category.listing" template="catalog/navigation/categories.phtml" />

My final right block looks as follows

<block type="core/text_list" name="right" as="right">
	<block type="catalog/navigation" name="featured" template="catalog/featured_random.phtml" />
	<block type="catalog/navigation" name="category.listing" template="catalog/navigation/categories.phtml" />
</block>

Template

Create the file template/catalog/navigation/categories.phtml and paste in the following

<div class="block block-layered-nav">
  <div class="block-title">
    <h2>Categories</h2>
  </div>
  <div class="block-content">
    <ul id="nav_category" class="nav_category">
    	<?php foreach ($this->getStoreCategories(true) as $_category): ?>
    		<?php echo $this->drawItem($_category) ?>
    	<?php endforeach ?>
    </ul>
  </div>
</div>
Filed under: Magento, PHP Leave a comment
Comments (2) Trackbacks (1)
  1. I’m new and I didn’t understend how to put all the categories of products in left colomn. I tested your steps and it didn’t work. I had edited page.xml file and created categories.phtml, it didn’t work.

    • Make sure that the categories.phtml is located in template/catalog/navigation. Also, instead of using the right block did you place the category.listing block line in your left block?


Leave a comment