2011-07-15 76 views
0

我對Magento的命名約定感到非常沮喪。目前,我試圖在模塊的管理部分顯示一些「hello world」。爲magento中的自定義模塊加載模塊塊

塊代碼位於

/var/www/magento/app/code/local/Polyvision/Tempest/Block/Adminhtml/View.php 

View.php的代碼:

$x = $this->getLayout()->createBlock('tempest/adminhtml_view'); 
var_dump($x); // false -> did not work 

<?php 

class Polyvision_Tempest_Block_Adminhtml_View extends Mage_Core_Block_Template 
{ 
    public function __construct() 
    { 
     parent::__construct(); 
    } 

    protected function _toHtml() 
    { 

     $html="hello world"; 

     return $html; 
    } 
} 
?> 

那麼,我爲什麼不能通過加載代碼結果我只是變得虛假。我嘗試了很多命名方案並查看了其他代碼,但我無法理解它爲什麼不起作用。

有些幫助會非常棒!

Regards,Alex

+0

你有沒有嘗試echo而不是返回$ html? – Nasaralla

+0

是的,我做到了。我還在構造函數中添加了一個die(),以查看它是否被加載,但沒有運氣。 – ghostrifle

+1

您是否在模塊的config.xml中定義了塊? – Simon

回答

1

好吧。上面的代碼有效。我的問題是一個小打字錯誤在我的config.xml

因此,爲大家,這是我正確的從我的config.xml全球部分:

<global> 
     <helpers> 
      <tempest> 
       <class>Polyvision_Tempest_Helper</class> 
      </tempest> 
     </helpers> 
     <blocks> 
      <tempest> 
       <class>Polyvision_Tempest_Block</class> 
      </tempest> 
      </blocks> 
    </global> 

日Thnx所有的建議!