views:

279

answers:

1

Hi all,

I am calling a block multiple times in the footer of my site as follows:

<reference name="footer">
    <block type="catalog/navigation" name="footer.category.occasion" as="cat_occasion">
        <action method="setTemplate"><template>catalog/category/menu.phtml</template></action>
        <action method="setData"><name>category_id</name><value>4</value></action>
    </block>

    <block type="catalog/navigation" name="footer.category.colour" as="cat_colour">
        <action method="setTemplate"><template>catalog/category/menu.phtml</template></action>
        <action method="setData"><name>category_id</name><value>3</value></action>
    </block>

    <block type="catalog/navigation" name="footer.category.flower" as="cat_flower">
        <action method="setTemplate"><template>catalog/category/menu.phtml</template></action>
        <action method="setData"><name>category_id</name><value>5</value></action>
    </block>

    <block type="catalog/navigation" name="footer.category.price" as="cat_price">
        <action method="setTemplate"><template>catalog/category/menu.phtml</template></action>
        <action method="setData"><name>category_id</name><value>6</value></action>
    </block>
</reference>

and here is menu.phtml:

<?php $id = $this->getCategoryId(); ?>
<?php $_category = Mage::getModel('catalog/category')->load($id); ?>

<h5><?php echo $_category->getName(); ?></h5>

<ul>
    <?php foreach (Mage::getModel('catalog/category')->load($id)->getChildrenCategories() as $_category): ?>
        <li>
            <a href="<?php echo $_category->getUrl(); ?>"><?php echo $_category->getName(); ?></a>
        </li>
    <?php endforeach; ?>
</ul> 

If I have the cache off all works fine. If I have the cache on then I get 4 duplicate lists, all as if I’d set category_id=4 (the first one).

Can anyone tell me how I can get 4 different lists with caching on?

Thanks in advance, Andrew :)

+1  A: 

I had this explained to me on the magento forum: http://www.magentocommerce.com/boards/viewthread/77264/

AndyFlan