即时通讯使用magento。这是加载我的左导航栏的代码。它将主要类别加载到一个ol中。我也想让它加载每个li中的子类别。我已经把加载孩子类别在这里我想知道的PHP代码来获取和显示上述父类别的所有子类别。我发现了几个修复程序,但不知道pHp很好导致了一系列错误。Magento:添加子菜单到左侧菜单
/**
* Category left navigation
*
* @see Mage_Catalog_Block_Navigation
*/
if (!Mage::registry('current_category')) {
//no current category selected so default to showing the Products category
$cur_category=Mage::getModel('catalog/category')->load(51);
$layer = Mage::getSingleton('catalog/layer');
$layer->setCurrentCategory($cur_category);
}else{
//current category selected so display the child categories for it
$layer = Mage::getSingleton('catalog/layer');
$_category = $layer->getCurrentCategory();
$currentCategoryId= $_category->getId();
if($currentCategoryId == 306){
//best sellers is selected so show the Product category
$cur_category=Mage::getModel('catalog/category')->load(51);
$layer = Mage::getSingleton('catalog/layer');
$layer->setCurrentCategory($cur_category);
}
}
$_categories=$this->getCurrentChildCategories();
$_count = is_array($_categories)?count($_categories):$_categories->count();
if($_count):
?>
<div class="box layered-nav">
<div class="head">
<h3><?php echo $this->__('Browse By') ?> PRODUCT CATEGORY</h3>
</div>
<div class="border-creator">
<div class="narrow-by">
<dl id="narrow-by-list">
<dd>
<ol>
<?php foreach ($_categories as $_category): ?>
<?php if($_category->getIsActive()): ?>
<li>
<a href="<?php echo $this->getCategoryUrl($_category) ?>"<?php if ($this->isCategoryActive($_category)): ?> class="active"<?php endif ?>><?php echo $this->htmlEscape($_category->getName()) ?></a>
**LOAD CHILD CATEGORIES IN HERE**
</li>
<?php endif; ?>
<?php endforeach ?>
</ol>
</dd>
</dl><script type="text/javascript">decorateDataList('narrow-by-list')</script>
</div>
</div>
</div>
<?php
endif;
?>
<!-- [ends] .browse-by // -->
到目前为止,我想出最好的,我知道它不是太大
<ul class="subnav">
<li><a></a>
</ul>
我感谢所有帮助极大
谢谢您的时间chanz, 我通过代码看,我理解它的一部分,但不是全部。 这是否代表我提供的代码顶部的if语句加载依赖页面的不同导航栏? 我知道它问了很多,但你能告诉我究竟在这个页面我需要插入它吗?我曾尝试过我最好的猜测,但它只是在随机的CMS页面中拉取任何分类链接。 – ATP