在左侧块上显示类别和子类别

时间:2012-11-05 12:38:02

标签: magento php

我想在左侧显示所选类别名称及其子类别。

应用\设计\前端\基\默认\模板\目录\导航\ left.phtml

在left.phtml中

<?php if (!Mage::registry('current_category')) return ?>
<?php $_categories = $this->getCurrentChildCategories() ?>
<?php $_count = is_array($_categories)?count($_categories):$_categories->count(); ?>
<?php if($_count): ?>
<div class="block block-layered-nav">
<div class="block-title">
    <strong><span><?php echo $this->__('Browse By') ?></span></strong>
</div>
<div class="block-content">
    <dl id="narrow-by-list2">


       <dt><?php echo $this->__('Category') ?>

        </dt>
        <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="current"<?php endif; ?>><?php echo $this->htmlEscape($_category->getName()) ?></a> (<?php echo $_category->getProductCount() ?>)
                </li>
                <?php endif; ?>
            <?php endforeach ?>
            </ol>
        </dd>
    </dl>
    <script type="text/javascript">decorateDataList('narrow-by-list2')</script>
    </div>
  </div>
  <?php endif; ?>

使用此代码类别列表可以查看但不显示类别名称,而是显示“CATEGORY”。如何查看当前的类别而不仅仅是CATEGORY?

1 个答案:

答案 0 :(得分:0)

您可以在此处获取当前类别

  

$ _ category = Mage :: registry('current_category');