Magento- How do I add a new custom block to the product details page using the module


I am doing a magento customaization site, I need to add the products addtional attributes like it's type,version etc .I am new to magento , How can i add the new custom block to product details page. I have created a module , and i am using below coding.


class SmartGrowth_CompatibleWith_Block_CompatibleWith extends Mage_Catalog_Block_Product_View


protected function _prepareLayout()




I have used the below coding in _prepareLayout() but it seem to be repeat the block 5 times and the location of the block appeared is a probs

$block = $this->getLayout()->createBlock(
array('template' => 'catalog/product/compatiblewith.phtml')

Please help how can i do this , I am new to magento , Any help will be appreciated.

There's no need to add the block in code, it should be done using config XML files.

Create an XML config for your module (plenty of tutorials on this).

check catalog.xml (app/design/frontend/base/default/layout/)

<catalog_product_view translate="label">

This is where the blocks are setup for display on the product view page. You can modify this using your own modules XML file, something like this:

<catalog_product_view translate="label">
    <reference name="content">
        <block type="compatiblewith/compatible" name="my.block" template="compatiblewith/compatible/template.phtml" />

this will show your custom block on the product view page, inside the content area.

You also have an error with the naming of your block if it's called Compatible.php the class should be SmartGrowth_CompatibleWith_Block_Compatible