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.

7ochem
7,61516 gold badges54 silver badges82 bronze badges
asked Jul 22, 2014 at 11:54

2 Answers 2

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.

answered Jul 22, 2014 at 12:09
9
  • I need to add my content in before add-to-cart button @mbalparda Commented Jul 22, 2014 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" /> Commented Jul 22, 2014 at 12:22
  • 1
    @VijayS. try adding an attribute before="addto" to the block tag in the example above. Commented Jul 22, 2014 at 12:22
  • @Marius I have try that above code its not working. Commented Jul 22, 2014 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. Commented Jul 22, 2014 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

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

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.