How can I access variables defined in the parent template inside a child template?
Example -> I added a new block with name product.info.grouped.news_flag as child of the block with name product.info.grouped in the catalog.xml layout of my design:
<PRODUCT_TYPE_grouped translate="label" module="catalog"> <label>Catalog Product View (Grouped)</label> <reference name="product.info"> <block type="catalog/product_view_type_grouped" name="product.info.grouped" as="product_type_data" template="catalog/product/view/type/grouped.phtml"> <block type="core/text_list" name="product.info.grouped.extra" as="product_type_data_extra" translate="label"> <label>Product Extra Info</label> </block> <!-- My new block --> <block type="core/template" name="product.info.grouped.news_flag" as="product_type_data_news_flag" template="catalog/product/view/type/news_flag.phtml"/> </block> </reference> </PRODUCT_TYPE_grouped> This is the part in the template file of the parent block where I call my new block with name product.info.grouped.news_flag:
catalog/product/view/type/grouped.phtml
<?php $testVar = 123; echo $this->getChildHtml('product_type_data_news_flag'); ?> As you can see I created a variable named $testVar with value 123.
But If I try to call the value in the child block product_type_data_news_flag then I get null:
catalog/product/view/type/news_flag.phtml
<?php $a = $testVar; echo $a; // returns null How can I pass a variable from the parent block/template to the child block/template?