I’m attempting to put a custom file containing featured items below the main product list on category pages on a Magento store.
I have edited catalog.xml to include:
<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>
<block type="catalog/product" name="featuredcat" as="featuredcat" template="customphp/featured-cat.phtml"/>
</block>
featuredcat.phtml includes a loop looking for products with a custom attribute (featured) selected. This works lovely, and is already in the sidebar.
I then add:
echo $this->getChildHtml('featuredcat')
To the bottom of my catalog/category/view.phtml file. But nothing rendering. I could have sworn this would be correct. Can anyone shed light as to what I’m doing wrong?
Cheers.
The layout xml you have provided has the
featuredcatblock appended directly to theproduct_listblock. So, you would have to callgetChildHtmlfrom withincatalog/product/list.phtmland notcatalog/category/view.phtml.So, you can either move your
getChildHtmlcall to the correct template as described above or movefeaturedcatblock up a level:Or you could keep your layout xml as is and use getChildChildHtml 🙂 – but I’m sure changing your layout is the better option –