我正在尝试覆盖Magento中特定类别的默认模板和块类。
以下代码仅更改模板
<reference name="product_list">
<action method="setTemplate"><template>catalog/product/list-foobar.phtml</template></action>
</reference>
我还需要将默认的Block Class从Mage_Catalog_Block_Product_List更改为Mage_Catalog_Block_Product_List_Foobar。
这可以在类别的“自定义布局更新”字段中使用XML吗?
我尝试过以下操作,但它也不起作用,
<reference name="product_list">
<block type="catalog/product_list_foobar" name="product_list" template="catalog/product/list-foobar.phtml" />
</reference>
答案 0 :(得分:1)
严格回答:
<CUSTOM_CATEGORY_DISPLAY>
<reference name="category.products">
<action method="unsetChild"><child>product_list</child></action>
<block type="catalog/product_list_foobar" name="product_list" template="catalog/product/list-foobar.phtml" />
</reference>
</CUSTOM_CATEGORY_DISPLAY>
然后,您可以在要应用这些指令的每个类别的自定义布局更新XML字段中使用<update handle="CUSTOM_CATEGORY_DISPLAY" />
。
但是,分层导航中涉及的模型和块之间存在一些奇怪/不幸的耦合,因此很可能会出现一些错误的行为。