本文主要是介绍左侧栏显示菜单!!,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
Main aims:
* Add the category tree of current viewing in left navigation sidebar instead of the “Browse by” box on top
* Remove the popup menu
There are 3 files that you need to change, including one hardcode file (navigation.php). Therefore, you better make sure that you already backup these files before changing them. And also, keep changing the hardcode file that way whenever you update your Margento version because it may change this file automatically. (My current ver is 1.4.0.1)
Get into your current theme in your Magento folder, in this case, my theme is “TRANGUYEN” :
1) app/design/frontend/default/TRANGUYEN/layout/catalog.xml : find and remove some codes in lines 82 to 84 like this
<!–<reference name=”left”>
<block type=”catalog/navigation” name=”catalog.leftnav” after=”currency” template=”catalog/navigation/left.phtml”/>
</reference>–>
2) skin/frontend/default/TRANGUYEN/css/styles.css : add these codes in line 1182 to 1188 like this, (max level = 5)
/*new code for leftnav*/
#leftnav li.level1 { padding-left:10px; }
#leftnav li.level2 { padding-left:20px; }
#leftnav li.level3 { padding-left:30px; }
#leftnav li.level4 { padding-left:40px; }
#leftnav li.level5 { padding-left:50px; }
/*end new code*/
3) app/code/core/Mage/Catalog/Block/navigation.php: this is the core code file of Magento, you need to add some codes in lines 223 and 234 as below:
Copy code:
if ($this->isCategoryActive($category)) { // new code for left navigation category tree
if ($hasChildren){
$j = 0;
$htmlChildren = ”;
foreach ($children as $child) {
if ($child->getIsActive()) {
$htmlChildren.= $this->drawItem($child, $level+1, ++$j >= $cnt);
}
}
if (!empty($htmlChildren)) {
/*$html.= ‘<ul>’.”/n” // new code for left navigation category tree
.$htmlChildren //
.’</ul>’;*/ //
$html .= $htmlChildren; //
}
}
}
Done. Enjoy !
这篇关于左侧栏显示菜单!!的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!