I'm trying to load a layout and set my custom phtml after the cart page.

But when I put the directives to load the layout, I have the following error:

Fatal error: Call to a member function getRequestedRouteName() on a non-object in /var/www/html/magento/edubras.dev/html/app/code/core/Mage/Core/Controller/Varien/Action.php on line 226


<?xml version="1.0"?>



My observer code:


class GrupoNDB_EmailCatcher_Model_Observer {

    public function __construct() {


    public function displayEmailCatcherPage($observer) {

        $frontA = new Mage_Core_Controller_Front_Action;

        $eCookie = Mage::getModel('core/cookie')->get("email");

        if( $eCookie == 'none'|| !isset($eCookie) || empty($eCookie) ) {
            echo Mage::app()->getLayout()->createBlock('core/template')->setTemplate('grupondb/email-catcher/cadastroEmail.phtml')->toHtml();

        // Call the block to fill the fields in checkout
        echo Mage::app()->getLayout->createBlock('core/template')->setTemplate('grupondb/email-catcher/set-email-field.phtml')->toHtml();



Someone can help me with this?


1 Answer 1


You should not use the Mage_Core_Controller_Front_Action this way and actually you don't need an observer for this at all.

Layout changes can be done via the layout xml files in app/design/frontend/YOURPACKAGE/YOURTHEME/layout/.

The standard layout file from the rwd theme is app/design/frontend/rwd/default/layout/checkout.xml.

You can update the template for a specific page and add the relevant part to your app/design/frontend/YOURPACKAGE/YOURTHEME/layout/local.xml

<checkout_onepage_index translate="label">
    <reference name="checkout.onepage">
        <block type="grupondb_emailcatcher/YOURBLOCKCLASS" name="checkout.emailcatcher.cadastroemail" as="cadastroemail" template="grupondb/email-catcher/cadastroEmail.phtml"/>
        <block type="grupondb_emailcatcher/YOURBLOCKCLASS" name="checkout.emailcatcher.setemailfield" as="setemailfield" template="grupondb/email-catcher/set-email-field.phtml"/>

Please note:

  • You also need to create the corresponding block classes to use this.
  • You did not mention where exactly you would like to insert your blocks so you might need to adjust either checkout_onepage_index or the reference name.

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.