Reputation: 415
I can't manage to show on a page, on the left side the categories. I selected for the page under Design - layout to 3 columns, Right side shows fine, but nothing on left side. New to magento so I'm not sure in which file in the template I have to look for. Its a custom template installed so I got so far to:
app/design/frontend/default/f001/template/
but not sure now if to look under catalog or page folders
Upvotes: 5
Views: 57163
Reputation: 11
Add this in left static block
<p>Left side bar {{block type="core/template" template="catalog/navigation/left.phtml"}}</p>
add left.phtml in yourtemplatename/template/catalog/navigation/left.phtml
<?php
$obj = new Mage_Catalog_Block_Navigation();
$store_cats = $obj->getStoreCategories();
$current_cat = $obj->getCurrentCategory();
$current_cat = (is_object($current_cat) ? $current_cat->getName() : '');
foreach ($store_cats as $cat) {
if ($cat->getName() == $current_cat) {
echo '<li class="current"><a href="'.$this->getCategoryUrl($cat).'">'.$cat->getName()."</a>\n<ul>\n";
foreach ($obj->getCurrentChildCategories() as $subcat) {
echo '<li><a href="'.$this->getCategoryUrl($subcat).'">'.$subcat->getName()."</a></li>\n";
}
echo "</ul>\n</li>\n";
} else {
echo '<li><a href="'.$this->getCategoryUrl($cat).'">'.$cat->getName()."</a></li>\n";
}
}
?>
Upvotes: 0
Reputation:
Go to layout Xml folder..
Blockquote /app/design/frontend/default/default/layout/catalog.xml
Open this Xml file and paste this code.
<reference name="left">
<block type="catalog/navigation" name="catalog.leftnav" template="catalog/navigation/left_nav.phtml" />
</reference>
further open this file ..
/app/design/frontend/default/default/template/catalog/navigation/left_nav.phtml
paste this code:
<?php
$obj = new Mage_Catalog_Block_Navigation();
$store_cats = $obj->getStoreCategories();
$current_cat = $obj->getCurrentCategory();
$current_cat = (is_object($current_cat) ? $current_cat->getName() : '');
foreach ($store_cats as $cat) {
if ($cat->getName() == $current_cat) {
echo '<li class="current"><a href="'.$this->getCategoryUrl($cat).'">'.$cat->getName()."</a>\n<ul>\n";
foreach ($obj->getCurrentChildCategories() as $subcat) {
echo '<li><a href="'.$this->getCategoryUrl($subcat).'">'.$subcat->getName()."</a></li>\n";
}
echo "</ul>\n</li>\n";
} else {
echo '<li><a href="'.$this->getCategoryUrl($cat).'">'.$cat->getName()."</a></li>\n";
}
}
?>
Upvotes: 12
Reputation: 1693
Go to Layout folder i.e.
app/design/frontend/default/f001/layout/
open any xml file e.g. catalog.xml and under tags
<default>
</default>
paste in this code
<reference name="left">
<block type="catalog/navigation" name="left_categories_nav" before="-" template="catalog/navigation/left.phtml"/>
</reference>
like this
<default>
<reference name="left">
<block type="catalog/navigation" name="left_categories_nav" before="-" template="catalog/navigation/left.phtml"/>
</reference>
</default>
But make sure to comment this block on line number 79.
<!-- <reference name="left">
<block type="catalog/navigation" name="catalog.leftnav" after="currency" template="catalog/navigation/left.phtml"/>
</reference> -->
Upvotes: 1
Reputation: 410
To move the categories from the right sidebar to the left sidebar you'll need to do this:
(1) Open app/design/frontend/default/f001/layout/ and find a file called local.xml - If it does not exist, create it.
Paste the following inside and save.
<?xml version="1.0" encoding="UTF-8"?>
<layout>
<default>
<!-- Left Categories Begin-->
<reference name="left">
<block type="catalog/navigation" name="catalog.leftnav" before="-" template="catalog/navigation/left.phtml"/>
</reference>
<!-- Left Categories End-->
</default>
</layout>
(2) Open app/design/frontend/default/f001/layout/catalog.xml
Inside "Category default layout", look for something like this and comment this line out (like so)-
<!-- <reference name="right">
<block type="catalog/navigation" name="catalog.leftnav" after="currency" template="catalog/navigation/left.phtml"/>
</reference> -->
That will prevent the categories from displaying on both sidebars, assuming you're using a 3 column.
The reference name, as you might have guessed, refers to each sidebar. You'll need to make sure that the reference name for "left" contains the left categories, and make sure the right does not (controlled in layout, not template files).
Upvotes: 0