1

I have added this xml in /app/design/frontend/rwd/default/layout/mymodule.xml

<layout version="1.0.1">
    <catalog_product_view>
        <reference name="product.info">
            <block type="mymodule/showicon" after="product.info.media" name="mymodule_showicon" template="mymodule/showicon.phtml" />
        </reference>
    </catalog_product_view>
</layout>

for testing I have shown following code in showicon.phtml afterwards I will show a image that I want to overlay the products image

<h1>SHOW ICON HERE</h1>

and in my confix.xml I have defined

    <config>
    <modules>
        <NS_Mymodule>
            <version>1.0.1</version>    <!-- Version number of your module -->
        </NS_Mymodule>
    </modules>

    <global>
        <helpers>
            <Mymodule>
                <class>NS_Mymodule_Helper</class>
            </Mymodule>
        </helpers>

        <blocks>
            <mymodule>
                <class>NS_Mymodule_Block</class>
            </mymodule>
        </blocks>

    </global>

    <frontend>
        <layout>
            <updates>
                <mymodule>
                    <file>mymodule.xml</file>
                </mymodule>
            </updates>
        </layout>
    </frontend>

</config>

Now as expected I don't see the text SHOW ICON HERE in my product page,

whats wrong, whats I'm missing?

UPDATE:

I've also added the block class with the code

class Ns_Mymodule_Block_Showicon extends Mage_Core_Block_Template
{
    public function myfunction()
    {
        return "Hello tuts+ world";
    }
}

I have also called the block in the view.phtml file at rwd/default/template/catalog/product

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

after this line

<?php echo $this->getChildHtml('alert_urls') ?>
2
  • Update your module config.xml here Sep 11, 2015 at 11:38
  • @PankajPareek please check now Sep 11, 2015 at 11:43

1 Answer 1

1

Change your layout xml as below:

<layout version="1.0.1">
<catalog_product_view>
    <reference name="content">
        <reference name="product.info">
            <block type="mymodule/showicon" after="product.info.media" name="mymodule_showicon" template="mymodule/showicon.phtml" />
        </reference>
    </reference>
</catalog_product_view>
</layout>

You need to add content reference as well. If you want to use above layout xml then you have to call the block in view.phtml

Update

Module Configuration (app\etc\modules\NS_Mymodule.xml)

<config>
<modules>
    <NS_Mymodule>
        <active>true</active>
        <codePool>community</codePool>
    </NS_Mymodule>
</modules>
</config>

Configuration XML (app\code\community\NS\Mymodule\etc\config.xml)

<config>
<modules>
    <NS_Mymodule>
        <version>1.0.1</version> 
    </NS_Mymodule>
</modules>
<global>
    <helpers>
        <Mymodule>
            <class>NS_Mymodule_Helper</class>
        </Mymodule>
    </helpers>
    <blocks>
        <mymodule>
            <class>NS_Mymodule_Block</class>
        </mymodule>
    </blocks>
</global>
<frontend>
    <layout>
        <updates>
            <mymodule>
                <file>mymodule.xml</file>
            </mymodule>
        </updates>
    </layout>
</frontend>
</config>

Block Class ( app\code\community\NS\Mymodule\Block\Showicon.php )

class Ns_Mymodule_Block_Showicon extends Mage_Core_Block_Template
{
public function myfunction()
{
    return "Hello tuts+ world";
}
}

Layout XML ( app\design\frontend\rwd\default\layout\mymodule.xml)

<layout version="1.0.1">
<catalog_product_view>
    <reference name="content">
        <reference name="product.info">
            <reference name="product.info.extrahint">
                <block type="mymodule/showicon" after="product.info.media" name="mymodule_showicon" template="mymodule/showicon.phtml" />
            </reference>
        </reference>
    </reference>
</catalog_product_view>
</layout>

Template File (app\design\frontend\rwd\default\template\mymodule\showicon.phtml)

Test Module

12
  • no, It doesn't work Sep 11, 2015 at 12:14
  • I have updated my answer Sep 11, 2015 at 12:34
  • still the same result, Sep 11, 2015 at 12:35
  • I created the module its working fine at my end. Sep 11, 2015 at 12:39
  • I have called the block in view.phtml like this <?php echo $this->getChildHtml('mymodule_showicon') ?> Sep 11, 2015 at 12:39

Your Answer

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

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