1
votes

i am a beginner in magento. I have added a custom module and made routing for that custom module. however it is not displaying anything at all, showing a blank page!!!! Not even the page not found message. here is my code..

my config file is as follows app/code/local/Test/Test/etc/config.xml

<config>
<modules>
    <Test_Test>
        <version>0.7.1</version>
    </Test_Test>
</modules>
<frontend>
    <routers>
        <test>
            <use>standard</use>
            <args>
                <module>Test_Test</module>
                <frontName>test</frontName>
            </args>
        </test>
    </routers>
<layout>
    <updates>
        <test>
            <file>test.xml</file>
        </test>
    </updates>
</layout>
</frontend>

my Test_Test.xml file in app/etc/modules/Test_Test.xml

<config>
    <modules>
        <Test_Test>
            <active>true</active>
            <codePool>local</codePool>
        </Test_Test>
    </modules>
</config>

my IndexController.php file in app/code/local/Test/Test/controllers/IndexAction.php

<?php
        class Test_Test_IndexController extends Mage_Core_Controller_Front_Action
    {
        public function indexAction()
        {
            $this->getLayout();
            $this->renderLayout();
        }
    }

my test.xml file in app/design/frontend/default/default/layout/test.xml

<layout version="0.7.0">
    <test_index_index>
        <reference name="root">
            <action method="setTemplate">
                <template>page/1column.phtml</template>
            </action>
        </reference>
        <reference name="content">
            <block type="test/view" name="test_index_view" template="test/view.phtml" />
        </reference>
     </test_index_index>
</layout>

my view.phtml file in app/design/frontend/default/default/template/test/view.phtml

<?php 
    echo "test test test test";
?>

i have called the following urls url 1:

http://localhost:8888/magento/index.php/test/index/index

url 2:

http://localhost:8888/magento/index.php/test/index

url 3:

http://localhost:8888/magento/index.php/test

url 4:

http://localhost:8888/magento/test

all of them shows a blank page as a result. not even showing the '404 not found 1' page . please help me to trigger out the problem. Thanks in advance..

2
You seems to miss the class Test_Test_Block_View, as you define the block in your layout xml. - Allen Koo
thanks for the reply.yes you are right. i have added following code to config.xml file<global> <blocks> <module> <class>Test_View_Block</class> </blocks> </global>. now the header and footer section came... however output not showing. please help - Rajeev K Tomy

2 Answers

5
votes

Multiple issues.

  • Your etc/config.xml file is missing a closing </config> tag.
  • You named your controller file IndexAction.php. It must be IndexController.php.
  • Your indexAction should use $this->loadLayout()->renderLayout();.
  • Your layout/test.xml uses an undefined block test/view. Use page/html for now.

After fixing these issues I can see your sample output of view.phtml on a naked 1.7.0.2.

1
votes

I am having similar problems with routing in Magento 1.7.0.2, although all module routing chain is right (checked many times for typos or missing elements, on different modules, cleared cache (also in var folders).

And after googling for hours and tring every possible solution, it appears that there is an issue with custom routing in Magento 1.7.0.2 (not 1.7).

Expecially with the pattern on your first three code chunks. However, if it helps you, you could try:

http://www.pierrefay.com/magento-create-controller-36 (specially the discussions in comments)

http://www.magentocommerce.com/knowledge-base/entry/magento-for-dev-part-3-magento-controller-dispatch

Hope it helps, please let us know if you have luck with this issue.