我正在尝试加载布局并在购物车页面后设置我的自定义phtml。
但是当我把指令加载到布局时,我有以下错误:
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
config.xml中:
<?xml version="1.0"?>
<config>
<modules>
<GrupoNDB_EmailCatcher>
<version>0.0.1</version>
</GrupoNDB_EmailCatcher>
</modules>
<global>
<blocks>
<grupondb_emailcatcher>
<class>GrupoNDB_EmailCatcher_Block</class>
</grupondb_emailcatcher>
</blocks>
<helpers>
<grupondb_emailcatcher>
<class>GrupoNDB_EmailCatcher_Helper</class>
</grupondb_emailcatcher>
</helpers>
<models>
<grupondb_emailcatcher>
<class>GrupoNDB_EmailCatcher_Model</class>
</grupondb_emailcatcher>
</models>
<events>
<controller_action_predispatch_onestepcheckout_index_index>
<observers>
<grupondb_emailcatcher>
<class>grupondb_emailcatcher/observer</class>
<method>displayEmailCatcherPage</method>
</grupondb_emailcatcher>
</observers>
</controller_action_predispatch_onestepcheckout_index_index>
</events>
</global>
</config>
我的观察员代码:
<?php
class GrupoNDB_EmailCatcher_Model_Observer {
public function __construct() {
}
public function displayEmailCatcherPage($observer) {
$frontA = new Mage_Core_Controller_Front_Action;
$frontA->loadLayout()->getLayout();
$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();
die;
}
// 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();
}
}
有人可以帮我这个吗?
干杯!