Happy Holidays everyone,
I'm in a quest to develop a block that shows 3 given categories within same view block.
I have this till now in my phtml file:
<?php
/**
* Displays multiple category view templates along with the product list for it
*/
/* @var $this Mage_Core_Block_Template */
$category_ids = explode(',', $this->getData('category_ids'));
$current_category = Mage::registry('current_category');
if ($current_category) {
Mage::unregister('current_category');
}
foreach ($category_ids as $it => $id) {
$category = Mage::getModel('catalog/category')->load(trim($id));
if (!$category->getId()) {
continue;
}
Mage::register('current_category', $category);
global ${"category_"$it} = $this->getLayout()->createBlock('catalog/product_list', 'product_list_'.$id, array('template' => 'catalog/product/list.phtml'));
Mage::unregister('current_category');
}
foreach ($category_ids as $it => $id) {
global array product_list ( array $product_list [, array ${"category_"$it}] );
}
Mage::register('current_category', 'category_1');
echo $this
->getLayout()
->createBlock('catalog/category_view', 'category_1', array('template' => 'catalog/category/view.phtml'))
->append($product_list, 'product_list')
->toHtml();
}
if ($current_category) {
Mage::unregister('current_category');
}
and I have this in my cms design page:
<reference name="content">
<block type="core/template" name="multiple_categories" template="catalog/category/multiple.phtml">
<action method="setData"><key>category_ids</key><val>12,13,26</val></action>
</block>
</reference>
This code is an adaptation of this answer, which successfully shows multiple categories, but with multiple blocks.
Unfortunately when I set code given above, my CMS page goes blank.
Does anyone know how to help me? Any tip is appreciated.