小编rus*_*man的帖子

Magento自定义左侧导航模板显示两次

我创建了一个自定义模板(mytheme/template/catalog/navigation/left_parent_category.phtml)来显示当前类别的父类别.

<?php


echo '<div class="box base-mini">';
echo '<ol>';
    $currentCat = Mage::registry('current_category');

    if ( $currentCat->getParentId() == Mage::app()->getStore()->getRootCategoryId() )
    {
        // current category is a toplevel category
        $loadCategory = $currentCat;
    }
    else
    {
        // current category is a sub-(or subsub-, etc...)category of a toplevel category
        // load the parent category of the current category
        $loadCategory = Mage::getModel('catalog/category')->load($currentCat->getParentId());
    }
    $subCategories = explode(',', $loadCategory->getChildren());

    foreach ( $subCategories as $subCategoryId )
    {
        $cat = Mage::getModel('catalog/category')->load($subCategoryId);

        if($cat->getIsActive())
        {
            echo '<li><a href="'.$cat->getURL().'">'.$cat->getName().'</a></li>';
        }
    }
echo '</ol>';
echo …
Run Code Online (Sandbox Code Playgroud)

php xml zend-framework magento

4
推荐指数
1
解决办法
6256
查看次数

标签 统计

magento ×1

php ×1

xml ×1

zend-framework ×1