0

enter image description hereI want to display my custom module template after Product title.

here's the code which I'm using currently.

<?xml version="1.0"?>
<layout version="0.1.0">
    <default>
        <reference name="content">
            <block type="core/template" as="shippingestimate" template="shippingestimate/shippingdate.phtml" />
        </reference>
    </default>
</layout>

Config.xml code

<frontend>
        <routers>
            <shippingestimate>
                <use>standard</use>
                <args>
                    <module>Wtw_Shippingestimate</module>
                    <frontName>shippingestimate</frontName>
                </args>
            </shippingestimate>
        </routers>
        <layout>
            <updates>
                <shippingestimate>
                    <file>shippingestimate.xml</file>
                </shippingestimate>
            </updates>
        </layout>
</frontend>

Just before Qty block.

Thanks

  • <?xml version="1.0"?> <layout version="0.1.0"> <default> <reference name="content"> <block type="core/template" as="shippingestimate" template="shippingestimate/shippingdate.phtml" /> </reference> </default> </layout> – Sartaj Feb 12 '18 at 12:16
  • Can you tell me where you want to show your custom module template? Product Listinfg page or view page etc? – Dhiren Vasoya Feb 12 '18 at 12:58
  • In your /catalog/product/view.phtml you need to do $this->getChildHtml('shippingestimate'); where you want it to appear – Ricky Odin Matthews Feb 12 '18 at 13:13
  • I'm creating my own custom module so i don't want to make any changes in core files. – Sartaj Feb 12 '18 at 13:16
1

yourlayoutModule.xml

<?xml version="1.0"?>
<layout version="0.1.0">
    <catalog_product_view>
        <reference name="root">
            <block type="core/template" name="shippingestimate" template="shippingestimate/shippingdate.phtml" />
        </reference>
    </catalog_product_view>
</layout>

app/design/frontend/{yourPackage}/{yourTheme}/catalog/product.view.phtml

and put the piece of code bellow where your want to display your block

<?php echo $this->getBlockHtml('shippingestimate'); ?>
  • why reference name="root" ? I think it should be content instead of root – Piyush Feb 12 '18 at 13:51
  • because Im not using a structural block, you have wrong in your solution, but I haven't downvoted you ;) – PЯINCƏ Feb 12 '18 at 13:57
  • So does this means that if we are not adding our xml code in catalog.xml, then we can add it in reference root and then call anywhere in the template using blockHtml? – Piyush Feb 12 '18 at 14:01
  • No, When you use reference name="root", you need to render this block in a template getChildHtml() or getBlockHtml(), however if you use reference name="content" you dont need to render it in a template, it will be added automatically ! why ? because content is a structural block of core/text_list type. – PЯINCƏ Feb 12 '18 at 14:12
  • I will try this, +1 for the explanation – Piyush Feb 12 '18 at 14:20

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.