0
votes

My php version is 5.5.11 And everything is up to date.

My plugin is being displayed in admin panel but when I visit the url it gives me error 404. Url: <sitename>/index.php/module/index

Testplugin_Module is enabled in admin panel.

Here is config file: locale/Testplugin/Module/etc/config.xml

    <?xml version="1.0"?>
    <config>
        <modules>
            <Testplugin_Module>
                <version>0.1.0</version>    <!-- Version number of your module -->
            </Testplugin_Module>
        </modules>
        <frontend>
            <routers>
                <module>
                    <use>standard</use>
                    <args>
                        <module>Testplugin_Module</module>
                        <frontName>module</frontName>
                    </args>
                </module>
            </routers>
<layout>
            <updates>
                <module>
                    <file>module.xml</file> <!-- Our layout file name-->
                </module>
            </updates>
        </layout>
    </frontend>
    <global>
        <blocks>
            <module>
                <class>Testplugin_Module_Block</class>
            </module>
        </blocks>
    </global>
    </config>

Here is the plugin: app/etc/modules/Testplugin_Module.xml

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

And here is the indexcontroller: locale/Testplugin/Module/controllers/IndexController.php

<?php
class Testplugin_Module_IndexController extends Mage_Core_Controller_Front_Action
{
    public function indexAction()
    {
        echo "Hello tuts+ World";
    }
}
?>

I have disabled cache from the admin panel, and I have tried restarting my lamp, and I have also tried logging in and logging out, still no success. Don't know what is wrong, any help would be appreciated.

Edit:

made the layout: I made the layout at app/design/frontend/base/default/layout/module.xml

<?xml version="1.0"?>
    <layout version="0.1.0">
        <module_index_index>
            <reference name="content">
                <block type="module/module" name="module" template="module/module.phtml" />
            </reference>
        </module_index_index>
    </layout>

Template: app/design/frontend/base/default/template/module/module.phtml

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

Block: local/Testplugin/Module/Block/Module.php

<?php

    class Testplugin_Module_Block_Module extends 

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

?>
2

2 Answers

2
votes

first of all add version in your Testplugin_Module.xml so magneto can identify which version it is and if you ever want to update so you can.

Testplugin_Module.xml app\etc\modules

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

Index.php app\code\local\Testplugin\Module\Block

<?php   
class Testplugin_Module_Block_Index extends Mage_Core_Block_Template{   





}

IndexController.php code\local\Testplugin\Module\controllers

<?php
class Testplugin_Module_IndexController extends Mage_Core_Controller_Front_Action{
    public function IndexAction() {

      $this->loadLayout();   
      $this->getLayout()->getBlock("head")->setTitle($this->__("module"));
            $breadcrumbs = $this->getLayout()->getBlock("breadcrumbs");
      $breadcrumbs->addCrumb("home", array(
                "label" => $this->__("Home Page"),
                "title" => $this->__("Home Page"),
                "link"  => Mage::getBaseUrl()
           ));

      $breadcrumbs->addCrumb("module", array(
                "label" => $this->__("module"),
                "title" => $this->__("module")
           ));

      $this->renderLayout(); 

    }
}

config.xml app\design\frontend\base\default\layout

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

module.xml app\design\frontend\base\default\layout

<?xml version="1.0"?>   
<layout version="0.1.0">   
  <module_index_index>   
    <reference name="root">   
      <action method="setTemplate"><template>page/1column.phtml</template></action>   
    </reference>   
    <reference name="content">   
      <block type="module/index" name="module_index" template="module/index.phtml"/>   
    </reference>   
  </module_index_index>   
</layout>   

index.phtml app\design\frontend\base\default\template\module

Hi, I am there!!

I think it start working now.

0
votes

you are missing to define layout file for your module as well as define layout tag in config.xml

I had try below code without rendering layout it working fine

Testplugin_Module.xml

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


config.xml 

<?xml version="1.0"?>
    <config>
        <modules>
            <Testplugin_Module>
                <version>0.1.0</version>    <!-- Version number of your module -->
            </Testplugin_Module>
        </modules>
        <frontend>
            <routers>
                <module>
                    <use>standard</use>
                    <args>
                        <module>Testplugin_Module</module>
                        <frontName>module</frontName>
                    </args>
                </module>
            </routers>
    	</frontend>
 </config>

IndexController.php

<?php
class Testplugin_Module_IndexController extends Mage_Core_Controller_Front_Action
{
    public function indexAction()
    {
        echo "Hello tuts+ World";
	exit;
    }
}
?>