1

I have created a custom module.

Below is my app/etc/modules/Php_CardReload.xml

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

Below is my app/code/local/Php/CardReload/etc/config.xml

<config>
    <modules>
        <Php_CardReload>
            <version>0.0.1</version>
        </Php_CardReload>
    </modules>
    <global>
    </global>
    <frontend>
        <routers>
            <reload>
                <use>standard</use>
                <args>
                    <module>Php_CardReload</module>
                    <frontName>reload</frontName>
                </args>
            </reload>
        </routers>
    </frontend>
    <layout>
        <updates>
            <cardreload>
                <file>php_cardreload.xml</file>
            </cardreload>
        </updates>
    </layout>
</config>

Below is my controller

<?php
    class Php_CardReload_MtoMController extends Mage_Core_Controller_Front_Action {
        function reloadCardAction(){
        $this->loadLayout();
            $this->renderLayout();

        }
    }
?>

Below is my php_cardreload.xml

<?xml version="1.0"?>
<layout version="0.0.1">
<default>    
        <reference name="top.links">
            <block type="checkout/links" name="checkout_cart_link">
                <action method="addCartLink"></action>
                <action method="addCheckoutLink"></action>
            </block>
        </reference>
        <reference name="right">
            .
            .
            .
        </reference>
    </default>
    <cardreload_mtom_reloadcard>
        <reference name="content">
            <!--<block type="cardreload/cardreload" name="cardreload" template="cardreload/cardreload.phtml" />-->
            <block type="core/template" name="cardreload" as="reload" template="page/card-summary.phtml"/>
        </reference>
    </cardreload_mtom_reloadcard>
</layout>

But the page.card-summary.phtml is not rendering. Also no log captured on system.log.

  • 2
    Please add this print_r($this->getLayout()->getUpdate()->getHandles()); to your controller after $this->loadLayout(); so you can see what are the actual handles. Most probably in your php_cardreload.xml you have to change <cardreload_mtom_reloadcard> to <reload_mtom_reloadcard>. – michael Sep 22 '15 at 11:01
  • @michael I printed as you said and the output is Array ( [0] => default [1] => STORE_default [2] => THEME_frontend_default_my_store [3] => reload_mtom_reloadcard [4] => customer_logged_out ) so I changed <cardreload_mtom_reloadcard> handle into <reload_mtom_reloadcard> now only the header and footer is loading not the main content. – Butterfly Sep 22 '15 at 11:09
  • check complier is enable or not? – Amit Bera Sep 22 '15 at 11:14
  • @AmitBera I enabled the compiler but still only the header and footer is loading. – Butterfly Sep 22 '15 at 11:34
  • I noted one interesting behavior. I delete all the php_cardreload.xml content and kept it empty still the header and footer is loading. – Butterfly Sep 22 '15 at 11:36
1

Some mistakes which I can see in your files;

1. layout file declaration is placed in wrong place

Layout definition should be inside frontend node. ie code should look like

<frontend>
    <routers>
        <cardreload>
            <use>standard</use>
            <args>
                <module>Php_CardReload</module>
                <frontName>reload</frontName>
            </args>
        </cardreload>
    </routers>
    <layout>
        <updates>
            <cardreload>
                <file>php_cardreload.xml</file>
            </cardreload>
        </updates>
    </layout>
</frontend>

2. Router configuration is wrong

your router unique identifier should be cardreload instead of reload. See above for the change.

3. controller class is wrong

Your controller class should be Php_CardReload_MtomController instead of Php_CardReload_MtoMController. Make sure path to your controller is app\code\local\Php\CardReload\controllers\MtomController.php instead of app\code\local\Php\CardReload\controllers\MtoMController.php

3. Controller action method is wrong.

It should be reloadcardAction instead of reloadCardAction.

After all changes made, please do clear your cache. Let me know whether it works or not

  • Awesome.. Thank you so much.. You saved one whole day :-) When I read your other post I thought you would solve this – Butterfly Sep 22 '15 at 12:23
  • 1
    @version.beta glad to help you out – Rajeev K Tomy Sep 22 '15 at 12:24
1
Replace your code with this:   
 <?xml version="1.0"?>
    <config>
        <modules>
            <Php_Cardreload>
                <version>0.0.1</version>
                <active>true</active>
                <codePool>local</codePool>
            </Php_Cardreload>
        </modules>
    </config>
    ---------------------------------------------------------------
    <config>
        <modules>
            <Php_Cardreload>
                <version>0.0.1</version>
            </Php_Cardreload>
        </modules>
        <global>
        </global>
        <frontend>
            <routers>
                <cardreload>
                    <use>standard</use>
                    <args>
                        <module>Php_Cardreload</module>
                        <frontName>reload</frontName>
                    </args>
                </cardreload>
            </routers>
        </frontend>
        <layout>
            <updates>
                <cardreload>
                    <file>php_cardreload.xml</file>
                </cardreload>
            </updates>
        </layout>
    </config>
 -------------------------------------   
    <?php
        class Php_Cardreload_MtomController extends Mage_Core_Controller_Front_Action 
        {
            function reloadcardAction(){
                $this->loadLayout();
                $this->renderLayout();

            }
        }
    ?>


   ------------------------------- 
    <?xml version="1.0"?>
    <layout version="0.0.1">
    <default>

            <reference name="top.links">
                <block type="checkout/links" name="checkout_cart_link">
                    <action method="addCartLink"></action>
                    <action method="addCheckoutLink"></action>
                </block>
            </reference>
            <reference name="right">

            </reference>
        </default>
        <cardreload_mtom_reloadcard>
            <reference name="content">
                <!--<block type="cardreload/cardreload" name="cardreload" template="cardreload/cardreload.phtml" />-->
                <block type="core/template" name="cardreload" as="reload" template="page/card-summary.phtml"/>
            </reference>
        </cardreload_mtom_reloadcard>
    </layout>
  • What have you changed on the above? Can you add some comments – Butterfly Sep 22 '15 at 11:48

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.