3

enter image description hereMy XML code is here

<?xml version="1.0"?>
<layout version="0.1.0">
<catalog_product_view>
    <reference name="product.info">
        <block type="demo/demo" before="product.description" name="demo" template="demo/demo.phtml" />
    </reference>
</catalog_product_view>
</layout> 

i want to put my block under product.info and above product.description

i dont to change any core file and dont want to use getChildHtml method

2

try this:

<catalog_product_view>
        <reference name="alert.urls"> 
            <block type="total/prototal"  name="total_prototal" template="total.phtml" />  
        </reference>
</catalog_product_view>

make sure this line must be exist in view.phtml file:

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

Hope this helps!

0

Go to the view file of your theme and add this at where you are willing to display the content..

Mage::app()->getLayout()->createBlock('modulename/blockname')->getFunctionName()->setTemplate('path_to_template');
0

You can control the order of your inserted blocks by the node's attribute before and after. See http://www.magentocommerce.com/knowledge-base/entry/controlling-block-order to get more info.

But, as you are setting your demo.demo block as a child of product.info it will not be rendered as child block, as long as you are not rendering it by getChildHtml inside catalog/product/view.phtml (product.info's template file).

Set your block not inside product.info but outside, right before it by the descripted technique mentioned above:

<catalog_product_view>
    <block type="demo/demo" before="product.info" name="demo" template="demo/demo.phtml" />
</catalog_product_view>

Child blocks are not automatically rendered by iterating through its children. There are just a few block types where this is true. See http://blog.philwinkle.com/the-most-misunderstood-concept-in-magento/ to get an understanding about this and the misconception of blocks in Magento.

Auto-rendered blocks

When defined in a layout, any block of type core/text_list will automatically render all its children. While core/text will automatically render itself it really only should contain text and therefore is not useful for layout purpose

and

Other blocks

Any other block type will need to be rendered manually. Provide the block an alias which can then be passed to getChildHtml, returning the content which you then echo.

to give you a tl;dr.

  • My xml is <?xml version="1.0"?> <layout version="0.1.0"> <default> </default> <catalog_product_view> <reference name="content"> <block type="demo/demo" name="demo" template="demo/demo.phtml" /> </reference> </catalog_product_view> </layout> i am trying to develop my extension and i want put this block under product.info is there any other way to put this block in product.info with out changing core files – Vaibhav Ahalpara Dec 25 '14 at 7:41
  • Use after="product.info" as attribute of your XML node if you want your output be rendered after product.info. Please understand that you can't change the order of the product.info children without editing template files or using dirty tricks. – Nicolas Dec 25 '14 at 7:57

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.