• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1362
  • Last Modified:

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...
0
rafique12
Asked:
rafique12
1 Solution
 
Chris StanyonCommented:
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 ?>
</ul>

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" />
</reference> 

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 :)
0
 
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!!!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now