2011-07-15 155 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所有的建议!