当用户向下滚动时,我在顶部添加了一个菜单fadeIn,如我的网站所示:http://homegym.sg
但是我无法编写类别。已经尝试了几个小时但无法找到解决方案。目前我已经在类别中进行了硬编码。如果我的PHP代码有效,您将能够在菜单中看到重复的类别。
以下是无法显示类别的代码:
<?php
/* Get the categories that are active for the store */
$_main_categories=$this->getStoreCategories();
/* Get the current category the user is in */
$_current_category=$this->getCurrentCategory();
/* Get the current category path */
$_categorypath = $this->getCurrentCategoryPath();
?>
<?php
if ($_main_categories):
foreach ($_main_categories as $_main_category):
if($_main_category->getIsActive()):
$cur_category=Mage::getModel('catalog/category')->load($_main_category->getId());
$layer = Mage::getSingleton('catalog/layer');
$layer->setCurrentCategory($cur_category);
?>
<li>
<a href="<?php echo $this->getCurrentCategory()->getUrl()?>"><?php echo $this->getCurrentCategory()->getName();?></a>
<?php $_maincategorylisting=$this->getCurrentCategory()?>
<?php $_categories=$this->getCurrentChildCategories()?>
<?php if($_categories->count()):?>
<ul class="subnav">
<? foreach ($_categories as $_category):?>
<? if($_category->getIsActive()):
$cur_subcategory=Mage::getModel('catalog/category')->load($_category->getId());
$layer = Mage::getSingleton('catalog/layer');
$layer->setCurrentCategory($cur_subcategory);
?>
<li><a href="<?php echo $this->getCategoryUrl($_category)?>"> <?php echo $_category->getName()?></a></li>
<? endif;?>
<?endforeach?>
</ul>
<? endif;?>
</li>
<?endif;?>
<?php $layer->setCurrentCategory($_current_category); ?>
<?php
endforeach;
endif;
?>