我试图创建一个自定义模块(学习目的)来显示特定用户的付款详细信息。致命错误:调用成员函数append()
我被困在块和布局,并得到了如下的错误之间:
Fatal error: Call to a member function 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();
}
}
你可以从错误中读出,你在呼唤一个关于它的任何方法之前,动态创建这个块不存在函数追加。 – Peon 2012-08-06 10:32:47
'$ this-> getLayout() - > getBlock('pitsnews')'返回的不是对象。请显示'var_dump($ this-> getLayout() - > getBlock('pitsnews'));' – DaveRandom 2012-08-06 10:39:29
@DaveRandom:是我调试了这一点,似乎我已经得到了解决方案。我想我在这里错过了一点。忘记在标记文件中添加布局。 pitsnews_payment_index>' –
Siva
2012-08-06 11:07:21