magento获得菜单分类代码
magento获得菜单分类代码,此代码在magento 1.4.2版本中使用正常,可以放在任意的.phtml文件中。此代码可以用来套用各种js菜单,实现各种各样的菜单效果。此代码来自互联网,非原创。代码如下
<div class="box layered-nav">
<div class="head">
<h3><?php echo $this->__('Browse By') ?></h3>
</div>
<h4><?php echo $this->__('Category') ?></h4>
<div class="content">
<div class="narrow-by">
<dl id="narrow-by-list">
<dd class="no-padding no-border">
<ol>
<?php
function showCategory( $current_category, $object )
{
if( !$current_category->getIsActive() )
return;
echo '<li>';
echo '<a href="' . $object->getCategoryUrl( $current_category ) . '"' .
($object->isCategoryActive( $current_category ) ? 'class="active"' : '' ) . '>';
echo $object->htmlEscape( $current_category->getName() );
echo '</a>';
echo $current_category->getProductCount();
if ( ( $children = $current_category->getChildren() ) && $children->count() )
{
echo '<ol>';
foreach ( $children as $child_category)
showCategory( $child_category, $object );
echo '</ol>';
}
echo '</li>';
}
$_categories=$this->getStoreCategories();
foreach ($_categories as $category)
showCategory( $category, $this );
?>
</ol>
</dd>
</dl>
<script type="text/javascript">decorateDataList('narrow-by-list')</script>
</div>
</div>
</div>
转载表明出处:hellokeykey.com

