How to show category on right side or left side in magento?

First of all you have to create a new block in xml to show the category
Navigate to /app/design/frontend/default/default/layout/catalog.xml

Open this page and search this keyword "Default layout, loads most of the pages"
and put this code in block

<reference name="right">

<block type="catalog/navigation" name="catalog.righthomenav" template="catalog/navigation/right_home_nav.phtml" />
</reference>

you can change layout position in mageto to change the reference name as (right, left, footer, etc)


create a new and directory like this path
 /app/design/frontend/default/default/template/catalog/navigation/ right_home_nav.phtml


and paste this code in that in new page right_home_nav.phtml


<h2>Browse</h2>
<div class="block">
<ul id="nav_category" class="nav_category">
 <?php foreach ($this->getStoreCategories() as $_category): ?>
  <?php echo $this->drawItem($_category) ?>
 <?php endforeach ?>
</ul>
</div>
<?php echo $this->getChildHtml('topLeftLinks') ?>



Note=> if you want to show this category list on home page only so paste this code in right_home_nav.phtml

<?php $routeName = Mage::app()->getRequest()->getRouteName();
$identifier = Mage::getSingleton('cms/page')->getIdentifier();
 
if($routeName == 'cms' && $identifier == 'home') { ?>
<h2>Related Category</h2>
<div class="block">
<ul id="nav_category" class="nav_category">
 <?php foreach ($this->getStoreCategories() as $_category): ?>
  <?php echo $this->drawItem($_category) ?>
 <?php endforeach ?>
</ul>
</div>
<?php echo $this->getChildHtml('topLeftLinks') ?>
<?php
}
?>
now refresh the cache and delete the session refresh the page works fine
thanks you to read my post



Comments