我試圖創建一個自定義模塊(學習目的)來顯示特定用戶的付款詳細信息。致命錯誤:調用成員函數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