4

I'm trying to use a different phtml file in an layout update for a category for the product_sublist.

Here's the catalog xml:

<reference name="content">
    <block type="catalog/category_view" name="category.products" template="catalog/category/view.phtml">
        <block type="catalog/product_list" name="product_sublist" template="catalog/product/subcatlist.phtml"> 
            <action method="setColumnCount"><count>5</count></action> 
            </block> 
        <block type="catalog/product_list" name="product_list" template="catalog/product/list.phtml">
            <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"/>
                <!-- The following code shows how to set your own pager increments -->
                <!--
                    <action method="setDefaultListPerPage"><limit>4</limit></action>
                    <action method="setDefaultGridPerPage"><limit>9</limit></action>
                    <action method="addPagerLimit"><mode>list</mode><limit>2</limit></action>
                    <action method="addPagerLimit"><mode>list</mode><limit>4</limit></action>
                    <action method="addPagerLimit"><mode>list</mode><limit>6</limit></action>
                    <action method="addPagerLimit"><mode>list</mode><limit>8</limit></action>
                    <action method="addPagerLimit" translate="label"><mode>list</mode><limit>all</limit><label>All</label></action>
                -->
            </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>

Trying to set in update, product_sublist to subcatlist_hardware.phtml.

Here's what I have and it's not working...

    <reference name="content">
            <block type="catalog/product_list" name="product_sublist" template="catalog/product/subcatlist_hardware.phtml"> 
                </block> 
    </reference

What am I missing or doing wrong?

  • Where did you put this? In the catalog.xml? – Melvyn Nov 17 '14 at 17:51
  • First code is from catalog.xml. The second code is what I used to in category layout update. – frshjb373 Nov 17 '14 at 17:54
  • Made an update above. Was able to add block via layout update, however the original block is still on page too. Any idea how to remove? – frshjb373 Nov 17 '14 at 18:21
  • Yes, use the same name. So product_list. You just added a block, but you want to replace the actual product list. The way you're doing it, is for example to add related products at the bottom of the page. – Melvyn Nov 17 '14 at 18:24
  • I have copied same list.phtml with another name and updated your code in custom design xml. but it seems pagination and sort dropdown is not working which is working with normal list.phtml please give me suggestion. Thanks – Prignesh Patel Dec 19 '15 at 14:04
10

If you just want to change the template for the product_list which based on the comments above I think is what your trying to achieve you can just reference the original name and then set a new template file name.

In your local.xml under whatever layout handle .eg <catalog_category_layered> you want this to update on you can do this:

<reference name="product_list">
<action method="setTemplate"><template>catalog/product/subcatlist.phtml</template></action>
</reference>

If you want to do this from the backend it's the same apart from you don't need to wrap a layout handle around the code.

enter image description here

  • I only want to update specific categories in layout update, but unfortunately this doesn't work for me. Any other ideas/methods? – frshjb373 Nov 17 '14 at 19:24
  • What xml file are you putting this into and can you share it? – James Anelay - TheExtensionLab Nov 17 '14 at 19:33
  • I'm trying to add a custom layout update in category in backend. To change the subcatlist.phtml to subcatlist_hardware.phtml only on applicable categories. Does that clarify? – frshjb373 Nov 17 '14 at 19:37
  • Ahh in the backend, ok two moments. – James Anelay - TheExtensionLab Nov 17 '14 at 19:39
  • Aslong as the block name is still "product_list" this should still work in the backend (see update). From your code I am not 100% sure if it's product_sublist or product_list that your trying to change - try both :) – James Anelay - TheExtensionLab Nov 17 '14 at 19:57

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.