Magento categories in Sidebar

Hi guys,

I've been working on a new Magento build and have become stuck with a relatively minor issue. I am trying to display categories in my right-sidebar. At the moment we have recently viewed and I can choose to add polls. However, when a customer chooses a category from the main navigation a list of categories gets displayed on the left-sidebar. I would like to display a list on the "right" for the homepage and products pages.

I have already activated 2-column-right so I know it can't be that but I am struggling here!!

PLease help...
Who is Participating?
Chris StanyonConnect With a Mentor Commented:
Basically, there are two steps to this. You need to create your HTML file for displaying the categories (Template) and then you need to tell Magento where and when to render the template (Layout).

Create your template file (sidebarCategories.phtml for example) in your theme's template folder (somewhere like /templates/catalog/navigation/). Add the following code:

<h2>Browse our Caetgories</h2>
<ul id="sidebar_cats">
	<?php foreach ($this->getStoreCategories() as $_category): ?>
		<?php echo $this->drawItem($_category) ?>
	<?php endforeach ?>

Open in new window

To add your new template to your store you need to create a block in the right column, so the XML for it is:

<reference name="right">
     <block type="catalog/navigation" name="sidebar.Categories" template="catalog/navigation/sidebarCategories.phtml" />

Open in new window

If your home page is a CMS page, then you need to edit the CMS page, and add the XML into the Layout Update XML - you'll find it on the Design tab of the CMS page.

For the products, you need to add it to the relevant XML file. This bit could be a bit confusing because you can add the XML in various places, so it will vary depending on your setup. You need to add it to the <catalog_product_view> handle...This could (should) be in a file called local.xml in your layout folder, but could be in a file called catalog.xml. It'll probably be in several. Start with local.xml, and then catalog.xml - but only in your themes folder (i.e don't edit the core files!)

Probably easier if you come back if you need help finding and editing the right file :)
rafique12Author Commented:
Top answer, I have been struggling with this allday! I hope you stick around as I'm going to more help - I just know it!!!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.