|
Alright, now that I’ve had more time look at the Magento database structure, here’s the updated query and code to display the left.phtml menu on the home page.
This example uses Magento v1.1.6
1. Copy/Paste the following code into line 67 of Navigation.php:
(app/code/core/Mage/Catalog/Block/Navigation.php)
/** * Retrieve child categories of root category * * @return Varien_Data_Tree_Node_Collection */ public function getMainCategories() { $collection = $this->getData('category_collection'); if (is_null($collection)) { $collection = Mage::getModel('catalog/category')->getCollection();
/* @var $collection Mage_Catalog_Model_Resource_Eav_Mysql4_Category_Collection */ $collection->addAttributeToSelect('url_key') ->addAttributeToSelect('name') ->addAttributeToSelect('is_anchor') ->addAttributeToFilter('is_active', 1) ->addAttributeToFilter('level', 2) ->setOrder('position', 'ASC') ->joinUrlRewrite() ->load(); $productCollection = Mage::getResourceModel('catalog/product_collection'); $productCollection->addCountToCategories($collection); } return $collection; }
2. Duplicate the left.phtml file (app/design/frontend/default/default/template/catalog/navigation/left.phtml) into the same directory and name it left_home.phtml.
3. Make the following changes to left_home.phtml
Search and remove:
<?php if (!Mage::registry('current_category')) return ?>
Search for:
getCurrentChildCategories()
Replace with:
getMainCategories()
4. Call the new left_home.phtml template in the Custom Design of the Home page.
CMS > Manage Pages > Click on Home page > Custom Design > Set the Layout field to “2 columns with left bar” or “3 columns” (if using the default install) and add the following code to top of the Layout Update XML textarea:
<reference name="left"> <block type="catalog/navigation" name="catalog.lefthome" before="-" template="catalog/navigation/left_home.phtml" /> </reference>
Have a look at your home page, if all went well you will see the added menu in the left column. If you are using the default install, you will also notice the blocks that used to be in the left column are now appearing above the center column content. You can remove them in the Content textarea under the General Information tab.
That should be it.
Hope someone finds this useful.
Kind regards,
LL
Image Attachments
Click thumbnail to see full-size image
|