Reputation: 7022
I am new in Magento. I am trying to develop a custom Module. 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>
<global>
<modules>
<Remote_Mouse>
<version>0.1.0</version>
</Remote_Mouse>
</modules>
<blocks>
<mouse>
<class>Remote_Mouse_Block</class>
</mouse>
</blocks>
</global>
<frontend>
<layout>
<updates>
<mouse module="Remote_Mouse">
<file>Remote_Mouse.xml</file>
</mouse>
</updates>
</layout>
<routers>
<mouse>
<use>standard</use>
<args>
<module>Remote_Mouse</module>
<frontName>remote</frontName>
</args>
</mouse>
</routers>
</frontend>
</config>
Location:
D:\php\htdocs\magento\app\design\frontend\my_theme\default\layout
mouse.xml
<?xml version="1.0"?>
<layout version="0.1.0">
<reference name="root">
<action method="setTemplate">
<template>page/1column.phtml</template>
</action>
</reference>
<mouse_index_index>
<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(array('default'));
$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??
Upvotes: 1
Views: 93
Reputation:
There is problem with your block type you have defined as following.
<block type="remote/brush" template="remote/mouse.phtml" />
That should be as below.
<block type="mouse/brush" template="remote/mouse.phtml" />
Upvotes: 1
Reputation: 897
If you trying to run /remote/index/index
action then you should have an error like myfunction function does not exists
. In your layout file you used
<block type="core/template" name="remote_mouse" template="remote/mouse.phtml" />
code while there should be:
<block type="mouse/mouse" name="remote_mouse" template="remote/mouse.phtml" />
Also make sure you placed all files according to their places. If you have no errors then maybe you template or layout files not in the correct theme templates/layouts directories. Thus it was no found by the system, system not tried to render it and call myfunction
method and so there's no error.
Also make sure the output for local modules isn't disabled.
Upvotes: 1