1

I want to call the Layered Navigation in my /catalog/product/list.phtml, so I used

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

Here is how my catalog.xml looks like:

<catalog_category_layered translate="label">
    <label>Catalog Category (Anchor)</label>
    <reference name="root">
        <block type="catalog/layer_view" name="catalog.leftnav" as="customFilterNav"  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">
                <!-- <action method="addReviewSummaryTemplate"><type>default</type><template>review/helper/su.phtml</template></action> -->
                <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>

Layered Navigation is set active for this category in the Magento Backend. Why doesn't it show anything? Do I have to set up another thing?

4
  • When you say "layered nav is set active..." do you mean "Is Anchor" is set to yes? Do you have any extensions that interact with layered navigation? What version of Magento are you using?
    – kab8609
    Dec 5, 2014 at 17:35
  • yes, I meant that, anchor is set to 'yes'. I am using Magento version 1.9.1.0 and I have installed the "multiple select" Extension, but it didn't work before either. It is here: magentocommerce.com/magento-connect/…
    – user980018
    Dec 5, 2014 at 17:41
  • Let me take a look at the release notes and set it up on my local to debug with you.
    – kab8609
    Dec 5, 2014 at 18:05
  • Thanks alot! I have my catalog.xml attached below, do you need the list.phtml also?
    – user980018
    Dec 5, 2014 at 20:12

2 Answers 2

1

You will need to insert the customFilterNav block inside of product_list like so:

<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/layer_view" name="catalog.leftnav" as="customFilterNav"  template="catalog/layer/view.phtml"/>
      </block>
    </block>
</reference>

You can only call getChildHtml on a block that is the child of the current block. Since you are calling it from product/list.phtml, which is being executed by the catalog/product_list block, your reference needs to be contained in that block

2
  • Hmm, this makes sense but sadly it didn't work :-( Did I do something wrong? chopapp.com/#zo3dbvfb
    – user980018
    Dec 5, 2014 at 20:09
  • Catalog product list block gets the products collection that is prepared by catalog/layer_view block so I'm not sure if it can be child of the catalog/product_list
    – Amasty
    Feb 13, 2015 at 9:50
1

There is a better method for getting any block by its name so you can leave layout XML as is and instead write

<?php echo $this->getLayout()->getBlock('catalog.leftnav')->toHtml() ?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.