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') ?>
  • Update your module config.xml here – Pankaj Pareek Sep 11 '15 at 11:38
  • @PankajPareek please check now – riksof-zeeshan Sep 11 '15 at 11:43
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

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

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.