在magento中为自定义模块加载模块的块

时间:2011-07-15 14:40:17

标签: magento module block adminhtml

我对Magento的命名惯例感到非常沮丧。目前,我正试图在我的模块的管理部分显示一些“hello world”。

块代码位于

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

View.php的代码:

<?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;
    }
}
?>

那么,为什么我不能通过以下方式加载代码:

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

我只是假装结果。我已经尝试了很多命名方案,并查看了其他代码,但我无法理解为什么它不起作用。

一些帮助会非常棒!

此致,Alex

1 个答案:

答案 0 :(得分: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!

相关问题