我有一个垂直导航菜单,它在悬停时显示带有图像缩略图和标题的父类别和子类别。我还想在子类别名称下方显示每个子类别的简短描述。目前,导航显示列表中每个子类别的父类别的描述。
我该如何改变?
这是代码:
<?php $_helper = Mage::helper('catalog/category') ?>
<?php $_categories = $_helper->getStoreCategories() ?>
<?php $currentCategory = Mage::registry('current_category') ?>
<?php if (count($_categories) > 0): ?>
<div class="left-nav-vertical visible-desktop visible-tablet hidden-phone" id="nav-vertical">
<ul class="nav nav-tabs-left" id="dcjq-vertical-mega-menu">
<li class="dropdown open visible-desktop visible-tablet hidden-phone" id="left">
<a class="dropdown-toggle"><?php echo $this->__('Shop by Department') ?><b class="caret"></b></a>
<ul class="dropdown-menu">
<ul id="mega" class="menu">
<!--Top Category-->
<?php foreach($_categories as $_category): ?>
<li id="menu-item-1">
<a href="<?php echo $_helper->getCategoryUrl($_category) ?>"> <?php echo $_category->getName() ?></a>
<ul>
<?php $_category = Mage::getModel('catalog/category')->load($_category->getId()) ?>
<?php $_subcategories = $_category->getChildrenCategories() ?>
<?php if (count($_subcategories) > 0): ?>
<?php foreach($_subcategories as $_subcategory):$products = Mage::getResourceModel('catalog/product_collection')->addCategoryFilter($_subcategory)->addAttributeToSelect('small_image');$products->getSelect()->order(new Zend_Db_Expr('RAND()'))->limit(1);$products->load();?>
<!-- SubCategory-->
<ul>
<li class="media">
<a href="<?php echo $_helper->getCategoryUrl($_subcategory) ?>">
<p class="product-name"><?php echo $_subcategory->getName() ?></p> </a>
<?php foreach($products as $product) { ?>
<?php $cur_category=Mage::getModel('catalog/category')->load($_category->getId());
$layer = Mage::getSingleton('catalog/layer');
$layer->setCurrentCategory($cur_category); ?>
<!-- Show image -->
<a href="<?php echo $_helper->getCategoryUrl($_subcategory) ?>" class="pull-left">
<img src="<?php echo $this->helper('catalog/image')->init($product, 'small_image')->resize(50, 50); ?>" class="static-thumbs" width="50" height="50" alt="<?php echo $_subcategory->getName() ?>" /></a>
<!-- End Show image-->
<!-- Show sub category Description -->
<li id="menu-item-4" class="pull-right">
<?php break; } ?>
<span><em>
<?php $children = explode( ",", $this->getCurrentCategory()->getChildren()); ?>
<?php foreach( $children as $child ): ?>
<?php $_child = Mage::getModel( 'catalog/category' )->load( $child ); ?>
<li><?php echo $_child->getDescription(); ?></li>
<?php endforeach; ?>
</em></span>
</li>
<!-- End show category Description -->
</ul>
<div class="clearer"></div>
<!-- end of subcats -->
<?php endforeach; ?>
</li>
<?php endif; ?>
</ul>
<!-- end of parent cats -->
<?php endforeach; ?>
</li>
</ul>
</ul>
</li>
</ul>
</div>
<?php endif; ?>
<!--- Close Navigation Menu -->
<script type="text/javascript">
jQuery.noConflict();
jQuery(document).ready(function(){
jQuery('#mega').dcVerticalMegaMenu({
rowItems: '1',
speed: 'fast',
effect: 'slide',
direction: 'right'
});
});
</script>
<!--- Closed Navigation Menu -->
我试过改变这一行:
<em><?php echo
> $this->htmlEscape($_category->getDescription()) ?></em>
对此:
<em><?php echo
> $this->htmlEscape($_subcategory->getDescription()) ?></em>
但没有快乐!
欢迎任何帮助...