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 に答える