Magento layered nav positioning on one column layo

2019-08-31 04:06发布

问题:

I can get the layered nav to appear in one column content using the following code but how do I control the vertical positioning? - at the moment it appears at the top no matter what I do. The category page is set to display a static block only.

<reference name="left">
    <action method="unsetChild"><name>catalog.leftnav</name></action>
</reference>
<reference name="content">
    <action method="insert"><child>catalog.leftnav</child></action>
</reference>

回答1:

"Content" block is a core/text_list block which means it will automatically display all it's children, in this case it will always display "catalog.leftnav" block. Look at 1column.phtml template:

<?php echo $this->getChildHtml('content') ?>

You need to change

<reference name="content">
    <action method="insert"><child>catalog.leftnav</child></action>
</reference>

to:

<reference name="category.products">
    <action method="insert"><child>catalog.leftnav</child></action>
</reference>

and modify catalog/category/view.phtml template by adding

<?php echo $this->getChildHtml('catalog.leftnav') ?> in a place you want to show layered nav.

That should solve your problem :-)



回答2:

You can simply add the layered nav block like below in catalog_category_default handler catalog.xml of your theme.

<catalog_category_default translate="label">
    <reference name="content">
        <block type="catalog/layer_view" name="catalog.contentnav" template="catalog/layer/view.phtml"/>
    </reference> 
</catalog_category_default>


标签: xml magento