2

I'm trying to move the layered navigation block from the left sidebar to a div in my /catalog/product/list.phtml

I did this successfully in my product category view, by adding getChildHtml('catalog.leftnav') ?> to /catalog/product/list.phtml. And then in local.xml I added

<catalog_category_layered>
  <!-- remove from left block -->
  <reference name="left">
    <action method="unsetChild">
      <child>catalog.leftnav</child>
    </action>
  </reference>

  <!-- add as child to product list block -->
  <reference name="product_list">
    <action method="insert">
      <child>catalog.leftnav</child>
    </action>
  </reference>
</catalog_category_layered>

So the question is, how do I do this for the search results view? Both pages include /catalog/product/list.phtml. I tried to do this in local.xml:

<catalogsearch_result_index>
  <!-- remove from left block -->
  <reference name="left">
    <action method="unsetChild">
      <child>catalogsearch.leftnav</child>
    </action>
  </reference>

  <!-- add as child to product list block -->
  <reference name="product_list">
    <action method="insert">
      <child>catalogsearch.leftnav</child>
    </action>
  </reference>

</catalogsearch_result_index>

But then the layered navigation block just disappeard from the search results page. I tried a few other combinations of things in the layout.xml file, but I'm just not knowledgable enough in Magento layouts to know what to do here. Can someone please point me in the right direction?

Thanks!

  • I think the layout handles are in the wrong order, so maybe the unsetChild is called and works, but insert is called on a block reference which doesn't exist yet. – Fabian Blechschmidt Jun 26 '14 at 22:29
4

The problem is that the name of the product list is different on the category page as on the search results page.

  1. Category: product_list
  2. Search results: search_result_list

So with this in mind the following code should work for you

<catalogsearch_result_index>
    <!-- remove from left block -->
    <reference name="left">
        <action method="unsetChild">
            <child>catalogsearch.leftnav</child>
        </action>
    </reference>

    <!-- add as child to product list block -->
    <reference name="search_result_list">
        <action method="insert">
            <child>catalogsearch.leftnav</child>
        </action>
    </reference>

</catalogsearch_result_index>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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