0

我正在尝试创建一个自定义模块(研究目的)来显示特定用户的付款详细信息。

我被困在块和布局之间,并收到如下错误:

致命错误:调用成员函数 append()

<?php
class PITS_Pitsnews_PaymentController extends Mage_Core_Controller_Front_Action {

    protected function _getSession() {
        return Mage::getSingleton('customer/session');
    }

    public function indexAction() {
        $this->loadLayout();
        $this->_initLayoutMessages('customer/session');
        $session = $this->_getSession();
        if (!$this->_getSession()->isLoggedIn()) {
            $this->_redirect('customer/account/login/');
            return;
        }
        $this->getLayout()->getBlock('pitsnews')->append(
            $this->getLayout()->createBlock('pitsnews/pitsnews')
        );
        $this->getLayout()->getBlock('pitsnews/pitsnews')->assign('data', $data);
        $this->renderLayout();
    }
}
4

1 回答 1

0

看起来像

$this->getLayout()->getBlock('pitsnews')

此处不是布局对象,因此请验证:

  • 如果您的布局标记将块注入此调度程序
  • 如果您的扩展中没有布局文件,那么您需要在调用任何方法之前动态创建此块
于 2012-08-06T10:59:42.920 回答