I want to be able to pass data to the getChildHtml() call. The reason is, the output of the block is dependant upon a product type. So i want to pass the product to the getChildHtml so that it can decide on the output.
I am doing this inside template/checkout/cart/item/default.phtml
.
Ideally, the call would look like:
echo $this->getChildHtml('child_block_name', $_item);
Then my block can get the product type from the item and display the correct output.
Since it is definitely not possible to pass this data to getChildHtml
- how else can this type of behaviour be achieved without having to rewrite the core block
The two solutions i currently have are as follows (neither very attractive):
1 - Create a helper and access the html output via the helper instead of letting a block and template render it ala $this->helper('my_module')->getItemHtml($_item);
2 - Access the child block and setData on it inside the template:
$this->getChild('child_name')->setData('item', $_item);
echo $this->getChildHtml('child_name')
I think in terms of the Magento architecture, number 2 is the lesser of two evils, but it is darn ugly looking inside a template.