cancel
Showing results for 
Search instead for 
Did you mean: 

Developing a Magento Module

SOLVED

Developing a Magento Module

I am new in Magento. I am trying to develop a custom Module. I am using Magento version. 1.8.1.0. My codes are as belows

 

Location: D:\php\htdocs\magento\app\etc\modules

 

Remote_Mouse.xml

 

<?xml version="1.0"?>
<config>
    <modules>
        <Remote_Mouse>
            <active>true</active>
            <codePool>local</codePool>
        </Remote_Mouse>
    </modules>
</config>

 

 

Location: D:\php\htdocs\magento\app\code\local\Remote\Mouse\etc

 

config.xml

 

<?xml version="1.0"?>
<config>    
    <modules>
        <Remote_Mouse>
            <version>0.1.0</version>
        </Remote_Mouse>
    </modules>    
    <frontend>        
        <routers>
            <mouse>
                <use>standard</use>
                <args>
                    <module>Remote_Mouse</module>
                    <frontName>mouse</frontName>
                </args>
            </mouse>
        </routers>
        <layout>
            <updates>
                <mouse>
                    <file>mouse.xml</file> 
                </mouse>
            </updates>
        </layout>        
    </frontend>
    <global>
        <blocks>
            <mouse>
                <class>Remote_Mouse_Block</class>
            </mouse>
        </blocks>
    </global>
</config>

 

 

Location:  D:\php\htdocs\magento\app\design\frontend\my_theme\default\layout

 

mouse.xml

 

<?xml version="1.0"?>
<layout version="0.1.0">
    <mouse_index_index>
        <reference name="root">
            <action method="setTemplate">
                <template>page/1column.phtml</template>
            </action>
        </reference>
        <reference name="content">
            <block type="remote/brush" template="remote/mouse.phtml" />
        </reference>
    </mouse_index_index>
</layout>

 

 

Location: D:\php\htdocs\magento\app\code\local\Remote\Mouse\Block

Brush.php

 

<?php
class Remote_Mouse_Block_Brush extends Mage_Core_Block_Template
{
    public function myfunction()
    {
        echo 'mouse';
    }
}

 

 

Location: D:\php\htdocs\magento\app\code\local\Remote\Mouse\controllers

IndexController.php

<?php
 
class Remote_Mouse_IndexController extends Mage_Core_Controller_Front_Action
{
    public function indexAction()
    {
        $this->loadLayout();
        $this->renderLayout();       
    }
 
    public function sayHelloAction()
    {
        echo 'Hello one more time...';
    }
}
?>

 

 

Location: D:\php\htdocs\magento\app\design\frontend\my_theme\default\template\remote

 

mouse.phtml

<?php
    echo $this->myfunction();
?>


I could not see any output. Is there any mistake in my code??

 

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Developing a Magento Module

Hello foysal,

 

Actually, our issue comes from your mouse.xml layout:

First of all, we don't have type="remote/brush" => should be type="mouse/brush"

Second, your block must declare a name: <block type="mouse/brush" name="mouse.brush" template="remote/mouse.phtml" />

Your mouse.xml should be:

 

<?xml version="1.0"?>
<layout version="0.1.0">
    <mouse_index_index>
        <reference name="root">
            <action method="setTemplate">
                <template>page/1column.phtml</template>
            </action>
        </reference>
        <reference name="content">
                <block type="mouse/brush" name="mouse.brush" template="remote/mouse.phtml" />
        </reference>
    </mouse_index_index>
</layout>

 

Problem solved? Click Accept as Solution!

View solution in original post

1 REPLY 1

Re: Developing a Magento Module

Hello foysal,

 

Actually, our issue comes from your mouse.xml layout:

First of all, we don't have type="remote/brush" => should be type="mouse/brush"

Second, your block must declare a name: <block type="mouse/brush" name="mouse.brush" template="remote/mouse.phtml" />

Your mouse.xml should be:

 

<?xml version="1.0"?>
<layout version="0.1.0">
    <mouse_index_index>
        <reference name="root">
            <action method="setTemplate">
                <template>page/1column.phtml</template>
            </action>
        </reference>
        <reference name="content">
                <block type="mouse/brush" name="mouse.brush" template="remote/mouse.phtml" />
        </reference>
    </mouse_index_index>
</layout>

 

Problem solved? Click Accept as Solution!