cancel
Showing results for 
Search instead for 
Did you mean: 

Search results block showing twice - how to customize via layout local.xml

Search results block showing twice - how to customize via layout local.xml

I need to add a custom nested block to the products.list block for category and search pages. For category, there's no issue unsetting category.products then redefining the block with my custom block included. However, for search, the same approach doesn't appear to work - I get two search.result blocks rendered even after unsetting it. It's highly possibly I'm missing something obvious here but can't see it. My xml definition in local.xml is as follows:

 

<catalogsearch_result_index>
        <reference name="root">
            <action method="setTemplate"><template>page/category.phtml</template></action>
        </reference>
        <reference name="content">
            <action method="unsetChild">
                <name>search.result</name>
            </action>
            <block type="catalogsearch/result" name="search.result" template="catalogsearch/result.phtml">
                <block type="catalog/product_list" name="search_result_list" template="catalog/product/list.phtml">
                    <block type="review_blocks/reviews_product_list" name="reviews" template="reviews/product/list.phtml"/>
                </block>
            </block>
        </reference>
    </catalogsearch_result_index>

So what I'm doing in the category default layout handle, which works, is as follows:

<catalog_category_default>
        <reference name="content">
            <action method="unsetChild">
                <name>category.products</name>
            </action>
            <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="review_blocks/reviews_product_list" name="reviews" template="reviews/product/list.phtml"/>
                </block>
            </block>
        </reference>
    </catalog_category_default>

Within list.phtml, I want to output the reviews for each product via:

<?php echo $this->getChild('reviews')->setProduct($_product)->toHtml() ?>

However, if I try as Marius suggested to do, I can't access my child block and get a fatal error with the above setProduct method.

 

Any help appreciated!