I tried to insert a getChildHtml in view.phtml file but half page is empty. The file that i would insert is a file with javascript/php/html code otherwise if i insert only html or php code the file is showing.

So...i declared my block in catalog.xml in this way:

block type="page/block"  name="product.info.calculator" as="calculator" template="catalog/product/view/calculator.phtml"

and in the view.phtml:

echo $this->getChildHtml('calculator');

Where is the problem?

  • in catalog.xml where did you add your code? under what reference ? Commented Feb 19, 2016 at 9:39
  • In Product view...in <catalog_product_view translate="label"> this is the position: <reference name="content"><block type="page/block" name="product.info.calculator" as="calculator" template="catalog/product/view/calculator.phtml"/> <block type="catalog/product_view_additional" name="product.info.additional" as="product_additional_data" /></reference>
    – Gabriel91
    Commented Feb 19, 2016 at 9:42

1 Answer 1


Here is how it should be:

<catalog_product_view translate="label">
    <reference name="content">
        <!-- Will show with out control on the product page -->

    <reference name="product.info">
        <!-- you can call it anywhere in the page using getChildHtml -->

  • I tried man but my getChildHtml not working. I show the content of file only i write in html and in php. If i past javascript code the result is the same. Half page is empty. Others possible solutions? Thank you.
    – Gabriel91
    Commented Feb 19, 2016 at 10:10
  • so you are saying the getChildHtml works but when you add javascript to your file it doesn't work? -- I'm happy to help but I need to understand Commented Feb 19, 2016 at 10:28
  • Exactly! Update: I saw that the problem is when i declare a variable on javascript, for example: <script type="text/javascript">var prezzo = "<?php echo ($_product->getFinalPrice());?>"...
    – Gabriel91
    Commented Feb 19, 2016 at 10:35
  • this will not work!!! you need to get the product collection in your file first. add this before your code $_product = Mage::registry('current_product'); Commented Feb 19, 2016 at 10:37
  • Man you're great!!! Now works!!! Thank you very much!!!! ;)
    – Gabriel91
    Commented Feb 19, 2016 at 10:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.