导航块渲染两次?

时间:2014-01-10 07:43:59

标签: magento templates

我尝试在自定义magento布局模板的左列中包含自定义类别导航。因此,我将以下代码放在local.xml

<!--Category View-->
<catalog_category_view>
    <!--Set Page Template-->
    <reference name="root">
        <action method="setTemplate">
            <template>page/hew_layout_2cl.phtml</template>
        </action>
    </reference>
    <reference name="left">
        <block type="catalog/navigation" name="catalog.catleftnav" template="catalog/category/navigation/left.phtml" />
    </reference>
</catalog_category_view> 

我的布局文件放在design/frontend/###CUSTOM###/default/template/page/layout_2cl.phtml中,并包含左列

的以下行
<div class="col-left sidebar"><?php echo $this->getChildHtml('left') ?></div>

left.phtml导航文件放在design/frontend/###CUSTOM###/default/template/catalog/category/navigation/left.phtml中,看起来像这样

<?php $_helper = Mage::helper('catalog/category') ?>
<?php $_categories = $_helper->getStoreCategories() ?>
<?php $currentCategory = Mage::registry('current_category') ?>
<?php if (count($_categories) > 0): ?>
<ul>
    <?php foreach($_categories as $_category): ?>
            <?php if ($currentCategory && $currentCategory->getId() == $_category->getId()): ?>
                <?php $_category = Mage::getModel('catalog/category')->load($_category->getId()) ?>
                <?php $_subcategories = $_category->getChildrenCategories() ?>
                <?php if (count($_subcategories) > 0): ?>
                        <?php foreach($_subcategories as $_subcategory): ?>
                            <li>
                                <a href="<?php echo $_helper->getCategoryUrl($_subcategory) ?>">
                                    <?php echo $_subcategory->getName() ?>
                                </a>
                            </li>
                        <?php endforeach; ?>
                <?php endif; ?>
            <?php endif; ?>
    <?php endforeach; ?>
</ul>
<?php endif; ?>

这里唯一的问题是左边的块被渲染两次。我也遵循以下thread的错误修复,但它没有帮助。

对此有何建议?谢谢!

0 个答案:

没有答案