Magento – Magento layout xml replace phtml file

layoutxml

i am writing my extension and i have troubles in my extension layout xml file. I need override my_theme/catalog/product/list.phtml to my_theme/myextension/mylist.phtml

I am trying to write the next code:

<?xml version="1.0"?>
<layout version="0.1.0">
     <catalog_category_layered>
         <reference name="catalog_product_list">
             <action method="setTemplate">
                 <template>myextension/mylist.phtml</template>
             </action>
         </reference>
     </catalog_category_layered>
 </layout>

But this no working. Help me please

Best Answer

To call methods on a block, you have to make sure two things:

  1. the block exists, when you try to call a method on it.
  2. you use the name of the block.

e.g. here:

<catalog_category_default translate="label">
    <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">
            ...

The name is product_list not catalog_product_list. And in the layered_navigation block it is product_list too, so change the reference and it should work

Related Topic