3

This is my controller

<?php 
class Karmick_Refer_IndexController extends Mage_Core_Controller_Front_Action{
    public function indexAction()
    {
        $this->loadLayout();
        $this->getLayout()->getBlock('head')->setTitle($this->__('Earn Money'));
         $this->renderLayout();
    }
    public function getCodeAction(){
        $this->loadLayout();

         $this->renderLayout();

    }
    public function checkAction(){
        die('Hello');
    }

}
?>

This is my layout xml file code

<?xml version="1.0"?>
<layout version="0.0.1">
<default>
    <remove name="left"/>
<reference name="head">
    <action method="addItem"><type>skin_css</type><name>css/karmick/check.css</name></action>
</reference>
<reference name="root">
            <action method="setTemplate"><template>page/2columns-right.phtml</template></action>
</reference>
</default>
<refer_index_index>
    <reference name="content">
        <block type="refer/refer" name="refer">
            <action method="setTemplate">
               <template>karmick/refer.phtml</template>
            </action>
        </block>
</reference>
</refer_index_index>
</layout>

This is my config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Karmick_Refer>
            <version>0.0.1</version>
        </Karmick_Refer>
    </modules>
    <frontend>
        <routers>
            <karmick_refer>
                <use>standard</use>
                <args>
                    <module>Karmick_Refer</module>
                    <frontName>refer</frontName>
                </args>
            </karmick_refer>
        </routers>


<layout>
<updates>
<karmick_refer>
<file>karmick/refer.xml</file>
</karmick_refer>
</updates>
</layout>
</frontend>
<global>
<models>
<refer>
<class>Karmick_Refer_Model</class>
<resourceModel>refer_mysql4</resourceModel>
</refer>
<refer_mysql4>
<class>Karmick_Refer_Model_Mysql4</class>
<entities>
<refer>
<table>karmick_refer</table>
</refer>
</entities>
</refer_mysql4>
</models>
<resources>
<refer_write>
<connection>
<use>core_write</use>
</connection>
</refer_write>
<refer_read>
<connection>
<use>core_read</use>
</connection>
</refer_read>
<refer_setup>
    <setup>
        <module>Karmick_Refer</module>
        <class>Karmick_Refer_Model_Resource_Mysql4_Setup</class>
    </setup>
</refer_setup>
<connection>
    <use>core_setup</use>
</connection>
</resources>
<helpers>
<refer>
<class>Karmick_Refer_Helper</class>
</refer>
</helpers>
<blocks>
<refer>
<class>Karmick_Refer_Block</class>
</refer>
</blocks>
</global>
</config>

But still my template file is not including.. When i am giving this code in Then template is coming..

Any idea what i am doing wrong??

15
  • Put your config.xml here Commented Mar 29, 2016 at 11:12
  • I update my question.. please check
    – Asish Hira
    Commented Mar 29, 2016 at 11:15
  • Clear cache or disable them Commented Mar 29, 2016 at 11:15
  • already disabled
    – Asish Hira
    Commented Mar 29, 2016 at 11:15
  • 2
    change refer_index_index to karmick_refer_index_index
    – Amit Bera
    Commented Mar 29, 2016 at 12:00

4 Answers 4

2

change refer_index_index to karmick_refer_index_index.

In config.xml you have define karmick_referas your frontname identifier for this extension.

  <routers>
            <karmick_refer> <!  frontName Identifier -->
                <use>standard</use>
                <args>
                    <module>Karmick_Refer</module>
                    <frontName>refer</frontName>
                </args>
            </karmick_refer>
        </routers>

Also whenevr a page layout load then a unique handle are created which are same as below format

'FrontNamaIdentifier_ControllerName_ActionName' .

So for your case it is karmick_refer_index_index.

0
0

Use this code in your layout xml:

<refer_index_index>   
    <reference name="content">   
      <block type="refer/refer" name="refer" template="karmick/refer.phtml"/>   
    </reference>   
  </refer_index_index> 
2
  • I have just updated my answer please use above code and let me know
    – Arunendra
    Commented Mar 29, 2016 at 11:27
  • Not worked :( :(
    – Asish Hira
    Commented Mar 29, 2016 at 11:30
0

You need to change

<refer_index_index>
    <reference name="content">
        <block type="refer/refer" name="refer" template="karmick/refer.phtml" />
    </reference>
</refer_index_index>
1
  • Not working Prashant.. :(
    – Asish Hira
    Commented Mar 29, 2016 at 11:32
0

Add bellow code in config.xml file

<?xml version="1.0"?>
<config>
    <modules>
        <Karmick_Refer>
            <version>0.0.1</version>
        </Karmick_Refer>
    </modules>             
    <frontend>
        <routers>
            <refer>
                <use>standard</use>
                <args>
                    <module>Karmick_Refer</module>
                    <frontName>refer</frontName>
                </args>
            </refer>
        </routers>
        <layout>
            <updates>
                <karmick_refer>
                    <file>karmick/refer.xml</file>
                </karmick_refer>
            </updates>
        </layout>
    </frontend>
<global>
<models>
<refer>
<class>Karmick_Refer_Model</class>
<resourceModel>refer_mysql4</resourceModel>
</refer>
<refer_mysql4>
<class>Karmick_Refer_Model_Mysql4</class>
<entities>
<refer>
<table>karmick_refer</table>
</refer>
</entities>
</refer_mysql4>
</models>
<resources>
<refer_write>
<connection>
<use>core_write</use>
</connection>
</refer_write>
<refer_read>
<connection>
<use>core_read</use>
</connection>
</refer_read>
<refer_setup>
    <setup>
        <module>Karmick_Refer</module>
        <class>Karmick_Refer_Model_Resource_Mysql4_Setup</class>
    </setup>
</refer_setup>
<connection>
    <use>core_setup</use>
</connection>
</resources>
<helpers>
<refer>
<class>Karmick_Refer_Helper</class>
</refer>
</helpers>
<blocks>
<refer>
<class>Karmick_Refer_Block</class>
</refer>
</blocks>
</global>
</config>

Add bellow code in block file Refer.php

<?php
class Karmick_Refer_Block_Refer extends Mage_Core_Block_Template
{
    protected function _prepareLayout()
    {

        return parent::_prepareLayout();
    }                  
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.