分类页左侧目录树二级分类显示其他父类分类

app\design\frontend\default\模板文件夹\layout\catalog.xml
<!--<block type="catalog/navigation" name="catalog.leftnav" before="-" template="catalog/navigation/left.phtml"/>-->
<block type="catalog/navigation" name="catalog.leftnav2" template="catalog/navigation/left2.phtml"/>  


新增:app\design\frontend\default\ 模板文件夹 \template\catalog\navigation\left2.phtml
<div class="block block-layered-nav-ft">
<div class="block-layerd-content">
<div class="block-layerd-contentin">
<!--    <div class="block-title">
     <strong><span><?php echo $this->__('Browse By') ?></span></strong>
    </div>-->
   <div class="block-content">
   <!--<dl id="narrow-by-list2">-->


<?php 
$_cat        = $this->getCurrentCategory();
$current_cat    = (is_object($_cat) ? $_cat->getName() : '');

switch( $_cat -> getLevel() ){
case '2':
default:
	$leftNav    = '<ul id="leftNav" name="leftNav">';
    $leftNav    .= '<li class="lefnavtwo"><a href="'.$this -> getCategoryUrl($_cat).'" class="a_white">'.$_cat -> getName().'</li>';
    $_categories    = $_cat->getChildrenCategories();
    $leftNav    .= '<ul>';
    foreach( $_categories as $_category ){
        $leftNav    .= '<li class="lefnavthree"><a href="'.$this -> getCategoryUrl( $_category ).'" >'.$_category -> getName().'</a>( '.$_category->getProductCount().')</li>';
    }
    $leftNav    .= '</ul>';
break;

case '3':
    $_parent    = $_cat -> getParentCategory();
    //$leftNav    .= '<li class="leftnav_title"><a href="'.$this -> getCategoryUrl($_parent).'">'.$_parent -> getName().'</a></li>';
		
    $_categories    = $_parent -> getChildrenCategories();
    $leftNav    .= '<ul>';
    foreach( $_categories as $_category ){
        $leftNav    .= '<li class="lefnavtwo">';
        if( $current_cat == $_category->getName() ){
            $leftNav    .= '<a class="currentCategory a_white" href="'.$this -> getCategoryUrl( $_category ).'" >'.$_category -> getName().'</a>';
            $leftNav    .= '<ul>';
            if( $_category -> hasChildren() ){
                $childCategoies    = $_category -> getChildrenCategories();
                foreach( $childCategoies as $_ccategory ){
                    $leftNav    .= '<li class="lefnavthree"><a href="'.$this -> getCategoryUrl( $_ccategory ).'" >'.$_ccategory -> getName().'</a>( '.$_ccategory->getProductCount().')</li>';
                }
            }
            $leftNav    .= '</ul>';
        }else{
            $leftNav    .= '<a class="a_white" href="'.$this -> getCategoryUrl( $_category ).'" >'.$_category -> getName().'</a>';
        }
        $leftNav    .= '</li>';
    }
    $leftNav    .= '</ul>';
break;
case '4':
    $_parent    = $_cat -> getParentCategory();
    $_pname        = $_parent -> getName();
    $_pparent    = $_parent -> getParentCategory();
   // $leftNav    .= '<li class="leftnav_title"><a href="'.$this->getCategoryUrl($_pparent).'">'.$_pparent -> getName().'</h3></li>';
    $_categories    = $_pparent -> getChildrenCategories();
    $leftNav    .= '<ul>';
    foreach( $_categories as $_category ){
        $leftNav    .= '<li class="lefnavtwo">';
        $leftNav    .= '<a class="a_white" href="'.$this -> getCategoryUrl( $_category ).'" >'.$_category -> getName().'</a>';
        if( $_pname == $_category->getName() ){
            $_categories    = $_category -> getChildrenCategories();
            $leftNav    .= '<ul>';
            foreach( $_categories as $_ccategory ){
                $leftNav    .= '<li class="lefnavthree">';
                if( $current_cat == $_ccategory -> getName() ){
                    $leftNav    .= '<a class="currentCategory" href="'.$this -> getCategoryUrl( $_ccategory ).'" >'.$_ccategory -> getName().'</a>';
                }else{
                    $leftNav    .=  '<a  href="'.$this -> getCategoryUrl( $_ccategory ).'" >'.$_ccategory -> getName().'</a>';
                }
                $leftNav    .= '</li>';
            }
            $leftNav    .= '</ul>';
        }
        $leftNav    .= '</li>';
    }
    $leftNav    .= '</ul>';
break;
}
echo $leftNav;
?>
</div></div></div></div>



skin\frontend\default\模板文件夹\blue\css\styles.css  进行样式修改

你可能感兴趣的:(目录树,Magento,分类页,显示其他父类分类,二级分类)