6

I have created a custom Extension.

In this Extension, I need to show some content in product description page.

How can i include that block using layout.xml.

<catalog_product_view translate="label">
    <reference name="content">
        <block type="catalog/product_view" name="product.info" template="catalog/product/view.phtml">
            .
            .
            .
            <-- My Block Load Here -->
            <block type="catalog/product_view" name="product.info.addto" as="addto" template="catalog/product/view/addto.phtml"/>
            .
            .
            .
        </block>
    </reference>
</catalog_product_view>

My Block Here:

<block type="xxx/yyyy" name="xxx.content" as="" template="xxx/xxx.phtml" />

What are the code add in my module xml file(app/design/frontend/default/default/layout/xxx.xml).

I no need to update anything in default phtml and layout file.

Please share your ideas.

Thanks.

2

Use inside your layout.xml

<catalog_product_view translate="label">
    <reference name="content">
        <block type="xxx/yyyy" name="xxx.content" as="" template="xxx/xxx.phtml" />
    </reference>
</catalog_product_view>

To position the block where you want, you can use before and after tags in your block as stated here.

9
  • I need to add my content in before add-to-cart button @mbalparda – VijayS91 Jul 22 '14 at 12:14
  • Get the name of the block and do <block type="xxx/yyyy" name="xxx.content" before="addto" as="" template="xxx/xxx.phtml" /> – mbalparda Jul 22 '14 at 12:22
  • 1
    @VijayS. try adding an attribute before="addto" to the block tag in the example above. – Marius Jul 22 '14 at 12:22
  • @Marius I have try that above code its not working. – VijayS91 Jul 22 '14 at 12:30
  • 1
    @MeenakshiSundaramR. Sorry but I have no idea. The only way I know to do this is to use a different template for the product view page. Basically copy the view template in your custom module, modify the block using layout files and tell it to use your template and then modify your template and inject your block there. Not very elegant. – Marius Jul 22 '14 at 12:57
2

Here the complete

First,check your current render is catalog_product_view

<catalog_product_view>
</catalog_product_view>

Then you reference blog name is name="product.info" So, put

<reference name="product.info">
</reference>

Third: put you block ,whose name should be unique.

<reference name="product.info">
        <block type="xxx/yyyy" name="xxx.content" as="" template="xxx/xxx.phtml" />
    </reference>

xxx.content is block name ,it is unique.

Then ,call this block using below code in phtml of reference block

$this->getChildHtml('blockname');

As i define block name is xxx.content then echo $this->getChildHtml('xxx.content'); in view.phtml file As catalog/product/view.phtml is reference phtml file

3
  • I dont want to add any code in phtml file. Please see my question – VijayS91 Jul 22 '14 at 12:30
  • Vijay,could not clearly in understrand "some content in product description page".Can you explain – Amit Bera Jul 22 '14 at 12:35
  • its may be a Html design, or content – VijayS91 Jul 22 '14 at 12:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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