Magento -在下拉菜单中显示父类和子类


Magento - displaying parent and child categories in a dropdown menu

我们目前正在Magento内的类别页面上工作,并有以下代码为我们所在的类别提供子类别列表。

我们有以下设置:

存储-第1类-光泽色(母色)-分目1 - Zurfiz(儿童)——子cat 2 - Parapan (Child)

下拉菜单截图:http://awesomescreenshot.com/048kga35a

我们希望修改代码,以显示"显示全部"的选项,并链接到下拉菜单中的父类别以及子类别,有人知道我们应该为此拉什么代码吗?

From app'design'frontend'default[our template]'template'catalog'navigation'left.phtml

<?php if (!Mage::registry('current_category')) return ?>
<?php $_categories=$this->getCurrentChildCategories() ?>
<?php 
    $oLayer = null;
    $oCat = $this->getCurrentCategory();
    # level 3 categories display their category siblings
    if (3 === (int)$oCat->getData('level')) {
        # get the layer object
        $oLayer = Mage::getSingleton('catalog/layer');
        $oParentCategory = $oCat->getParentCategory();
        # set the parent category as the current category
        $oLayer->setData('current_category',$oParentCategory);
        # load the child categories
        $_categories = $this->getCurrentChildCategories();
    }
?>
<?php if($_categories->count()): ?>
<div class="box layered-nav">
    <?php
        # switch back the current category
        if (null !== $oLayer) $oLayer->setData('current_category',$oCat);
    ?>
<script language="javascript" type="text/javascript" >
function jumpto(x){
if (document.form1.jumpmenu.value != "null") {
document.location.href = x
}
}
</script>
<div class="cat-dropdown">
      <form name="catlist">
        <select name="jumpmenu" onChange="jumpto(document.catlist.jumpmenu.options[document.catlist.jumpmenu.options.selectedIndex].value)">
        <option value="#">Choose a brand</option>
                <?php foreach ($_categories as $_category): ?>
                    <?php if($_category->getIsActive()): ?>
          <option value="<?php echo $this->getCategoryUrl($_category) ?>"><?php echo $this->htmlEscape($_category->getName()) ?> (<?php echo $_category->getProductCount() ?>)</option>
                              <?php endif; ?>
                <?php endforeach ?>
        </select>
      </form>
</div>
</div>
<?php endif; ?>

使用此代码…

<?php
//$id = whatever
$subcats  = Mage::getModel('catalog/category')->load($id)->getAllChildren();
?>
<select name="jumpmenu">
<option value="#">Choose a brand</option>
<?php
foreach(explode(',',$subcats) as $subCatid)
{
   $_category = Mage::getModel('catalog/category')->load($subCatid);
       //print_r($_category);
 ?>
   <option value="<?php echo $_category->getCategoryUrl() ?>"><?php echo htmlEscape($_category->getName()) ?></option>
<?php } ?>
</select>