2

Seems a standard use case but I didn't find a working solution, so I post it here.

In base/default/layout/catalog.xml I see:

<catalog_product_view translate="label">
    <reference name="content">
        <block type="catalog/product_view" name="product.info" template="catalog/product/view.phtml">
            ....
        </block>
    </reference>
</catalog_product_view>

I need to add a block within the product.info block, so in my local.xml I tried:

<catalog_product_view>
    <reference name="product.info">
        <block type="core/product_view" name="sticazzi" as="sticazzi" template="catalog/product/view/sticazzi.phtml"/>
    </reference>
</catalog_product_view>

and in my view.phtml I put:

<?php echo $this->getChildHtml('sticazzi') ?>

This does not work, what's wrong? Thanks

2 Answers 2

2

Your code is half correct change type="core/product_view" to type="catalog/product_view"

<reference name="product.info">
    <block type="catalog/product_view" name="sticazzi" as="sticazzi" template="catalog/product/view/sticazzi.phtml"/>
</reference>

If you use <reference name="content"> this will load the block without getChildHTml

2
  • sorry, I did exactly what you wrote here and it does not work. my question is wrong, I will update it.
    – davideghz
    Commented May 11, 2017 at 10:43
  • catalog/product_view not core/product_view Commented May 11, 2017 at 10:44
1

If you want to display it in view.phtml then you need to use of that reference block like below

<reference name="product.info">
    <block type="catalog/product_view" name="sticazzi" as="sticazzi" template="catalog/product/view/sticazzi.phtml"/>
</reference>

Now you can use it in view.phtml

<?php echo $this->getChildHtml('sticazzi') ?>

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.