1

I have created a controller to display the some text, but it's not displaying?

Can you any one tell me where I went wrong?

my code is

->local->Test->EasyLife->Block //Template.php

<?php

class Test_EasyLife_Block_Template extends Mage_Core_Block_Template
{
    public function methodblock()
    {
        echo "Hello Bojjaiah!";
    }
}

->local->Test->EasyLife->controllers

//IndexController.php

<?php
class Test_EasyLife_IndexController extends Mage_Core_Controller_Front_Action
{
    public function indexAction()
    {
        //echo "Hello Bojjaiah!";
        $this->loadLayout();
        $this->renderLayout();
    }

    public function mamethodeAction()
    {
        echo "test mamethode";
    }

}

->local->Test->EasyLife->etc

//config.xml

    <?xml version="1.0"?>
<config>
    <modules>
        <Test_EasyLife>
            <version>0.0.1</version>
        </Test_EasyLife>
    </modules>
    <frontend>
        <routers>
            <testcontroller>
                <use>standard</use>
                <args>
                    <module>Test_EasyLife</module>
                    <frontName>display</frontName>
                </args>
            </testcontroller>
        </routers>
        <layout>
            <updates>
                <easylife>
                    <file>easylife.xml</file>
                </easylife>
            </updates>
        </layout>
    </frontend>
    <global>
        <blocks>
            <easylife>
                <class>Test_EasyLife_Block</class>
            </easylife>
        </blocks>
    </global>
</config>

->etc->modules-> //Test_EasyLife.xml

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

->default->test->layout

//easylife.xml

<?xml version="1.0"?>
<layout version="0.1.0">
    <default>
        <reference name="root">
            <action method="setTemplate"><template>page/3columns.phtml</template></action>
            <!-- Mark root page block that template is applied -->
            <action method="setIsHandle"><applied>1</applied></action>
        </reference>
        <reference name="content">
            <block type="easylife/template" name="easylife.template" template="easylife/mytemplate.phtml">
            </block>
        </reference>
    </default>
</layout>

->default->test->template->easylife

//mytemplate.phtml

<div>
    <h1>Hi Bojjaiah!</h1>
    <h2><?php $this->methodblock(); ?></h2>
</div>

my output is

enter image description here

thanks in advance.

  • What is the url you are testing on? and stop using my 'unofficial' namespace Easylife as a module name. :). Just kidding. Use whatever you want. – Marius Sep 30 '13 at 6:58
  • have you cleared the cache? does your module show up in admin System\Advanced\Advanced ? – user487772 Sep 30 '13 at 7:38
1

From your screen shot it looks like you are using the default template, but you seem to have added your template and layout xml into the wrong folders.

Try moving your template to:

base->default->template->test->mytemplate.phtml

And you layout xml to:

base->default->layout->easylife
  • hi david, it's working fine, but I created my own package(Test), why not it's not execute when I select my package under configuration->General->design->Thems->default=Test – Manoj Kumar Sep 30 '13 at 7:18
  • I think it is case sensitive so if you change it from "Test" to "test" does that now work with your new template and layout? – David Manners Sep 30 '13 at 7:20
  • hi david it's not working eventhoug I given Test. – Manoj Kumar Sep 30 '13 at 7:26
  • just to confirm that the case of the folder matches that of the theme in the admin section e.g. the folder "Test" and the theme "Test". – David Manners Sep 30 '13 at 7:33
  • you could also try turning on template hints via the admin section to see what template it is trying to call – David Manners Sep 30 '13 at 8:30

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.