不久前,我在这个网站上设置了左侧导航:http: //makethemostof.co.uk/以在顶级类别上显示所有子类别,并在子类别上显示所有同级类别。
我现在想向子类别(但不是父类别)添加分层导航。分层导航工作正常,但我用于显示同级类别的代码不再有效。请在此处查看:http ://makethemostof.co.uk/house-garden/kitchen可以在父级(“房屋和花园”)中找到的列表应该出现在过滤器上方,但事实并非如此。
这就是我在 layout/catalog.xml 中的内容:
<catalog_category_layered translate="label">
<label>Catalog Category (Anchor)</label>
<reference name="root">
<action method="setTemplate"><template>page/2columns-left.phtml</template></action>
</reference>
<reference name="left">
<block type="catalog/navigation" name="catalog.leftnav" template="catalog/navigation/left.phtml"/>
<block type="mana_filters/view_category" name="mana.catalog.leftnav" template="catalog/layer/view.phtml"/>
<!--<block type="catalog/layer_view" name="catalog.filters" template="catalog/layer/view.phtml"/>-->
</reference>
<reference name="content">
<block type="catalog/category_view" name="category.products" template="catalog/category/view.phtml">
<block type="catalog/product_list" name="product_list" template="catalog/product/list.phtml">
<block type="catalog/product_list_toolbar" name="product_list_toolbar" template="catalog/product/list/toolbar.phtml">
<block type="page/html_pager" name="product_list_toolbar_pager"/>
</block>
<action method="addColumnCountLayoutDepend"><layout>empty</layout><count>6</count></action>
<action method="addColumnCountLayoutDepend"><layout>one_column</layout><count>5</count></action>
<action method="addColumnCountLayoutDepend"><layout>two_columns_left</layout><count>4</count></action>
<action method="addColumnCountLayoutDepend"><layout>two_columns_right</layout><count>4</count></action>
<action method="addColumnCountLayoutDepend"><layout>three_columns</layout><count>3</count></action>
<action method="setToolbarBlockName"><name>product_list_toolbar</name></action>
</block>
</block>
</reference>
</catalog_category_layered>
这是我在模板/目录/导航/left.phtml 中的内容:
<?php $currentCat = Mage::registry('current_category');
if ( $currentCat->getParentId() == Mage::app()->getStore()->getRootCategoryId() ) {
echo '<h2 class="grad">'.$this->getCurrentCategory()->getName().'</h2>';
$loadCategory = $currentCat;
} else {
echo '<h2 class="grad"><a href="'.$this->getCurrentCategory()->getParentCategory()- >getURL().'">'.$this->getCurrentCategory()->getParentCategory()->getName().'</a></h2>';
$loadCategory = Mage::getModel('catalog/category')->load($currentCat->getParentId());
}
$cats = $loadCategory->getChildrenCategories(); ?>
<ul>
<?php foreach($cats as $category): ?>
<? $category->load();
if ($category->getIsActive() && $category->getIncludeInMenu()) { ?>
<li>
<a href="<?php echo $category->getUrl() ?>"><?php echo $category->getName() ?></a>
</li>
<? } ?>
我只能假设上面某处有错误。任何识别它的帮助将不胜感激。谢谢!