4

I want to add something (a small text or image) before the price.

The only way to do is to update the catalog_product_view template and copy the whole view.phtml in my module and then add the thing i want into my updated/modified view.phtml?

Why i can't add a block inside the block like this?

<catalog_product_view>
        <reference name="product.info">
            <block type="core/template" name="product.info.something" template="path/to/my/something.phtml"/>
        </reference>
</catalog_product_view>

Is there another way to do this without copy/paste(overriding) the whole view.phtml in my module?

2 Answers 2

5

Look at your layout.xml

<catalog_product_view>
        <reference name="product.info">
            <block type="core/template" name="product.info.something" template="path/to/my/something.phtml"/>
        </reference>
</catalog_product_view>

If you declare your custom block inside the layout.xml, then you MUST call this block inside the catalog/product/view.phtml as belows. Any way you have to copy this template inside your custom module's template folder and call it.

<?php echo $this->getChildHtml('product.info.something'); ?>
1

There are two ways to output child blocks: * separate by name * all together (like the content block)

As most blocks dont have an "output all" you would need to add an output for this block name.

Or you see, which child blocks have an output all, which for example is every block of type "core/text_list"

So in your case you could add your content in extrahint. But this would be after the price.

To get near to your requirements you could move the output via CSS or a bit hacky via javascript (price block makes heavy use of javascript anyway).

There would be more solutions, but the work for them is way to high for a simple template change. So if your change is only for this project, copy/paste the view.phtml would be ok too. You could simple separate your content into an own block and only add your "getChildHtml($blockname)" line.

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.