Magento categories in Sidebar

Posted on 2012-08-18
Last Modified: 2012-08-18
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...
Question by:rafique12
    LVL 42

    Accepted Solution

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

    Author Closing Comment

    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!!!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Suggested Solutions

    E-commerce is quite a gambling world, and you should never entrust your business to a lucky chance. In order to outrun your competitors in a race to attract as many customers as possible, you need to have a well thought-out strategy under your belt.…
    These days socially coordinated efforts have turned into a critical requirement for enterprises.
    In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
    In this tutorial viewers will learn how to style different bullet points for unordered lists in CSS. Begin with a normal unordered list; the default bullet point is a solid circle: In the CSS, create a defined class of unordered list by typing "ul.S…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now