Magento没有显示自定义块

时间:2012-01-31 18:08:17

标签: magento layout block

在我的config.xml中,我有:

<config>
    <modules>
        <Test_Quickorder>
            <version>0.1.0</version>
        </Test_Quickorder>
    </modules>
    <global>
        <blocks>
            <quickorder>
                <rewrite>
                    <quickorder>Test_Quickorder_Block_Quickorder</quickorder>
                </rewrite>
            </quickorder>
        </blocks>
    </global>
    <frontend>
        <routers>
            <quickorder>
                <use>standard</use>
                <args>
                    <module>Test_Quickorder</module>
                    <frontName>quickorder</frontName>
                </args>
            </quickorder>
        </routers>
        <layout>
            <updates>
                <quickorder>
                    <file>quickorder.xml</file>
                </quickorder>
            </updates>
        </layout>
    </frontend>
</config>

在app / code / community / Test / Quickorder / controllers / IndexController.php我有:

<?php
class Test_Quickorder_IndexController extends Mage_Core_Controller_Front_Action
{
    public function indexAction()
    {
        $this->loadLayout(array('default');
        $this->renderLayout();
    }
}

在app / design / frontend / base / default / layout / quickorder.xml中我有:

<layout version="0.1.0">
    <default>
        <reference name="top.links">
            <action method="addLink" translate="label title">
                <label>Quick Order</label>
                <url>quickorder</url>
                <title>Quick Order</title>
                <prepare/>
                <urlParams/>
                <position>1</position>
            </action>
        </reference>
    </default>
    <quickorder_index_index>
        <reference name="root">
            <action method="setTemplate">
                <template>page/1column.phtml</template>
            </action>
        </reference>
        <reference name="content">
            <block type="quickorder/quickorder" name="quick" template="quickorder/quickorder.phtml"/>
        </reference>          
    </quickorder_index_index>
</layout>

在app / design / frontend / base / default / template / quickorder / quickorder.phtml我有:

<div class="content">
    <p>Hello</p>
</div>

在app / code / community / Test / Quickorder / Block / Quickorder中我有:

<?php
class Test_Quickorder_Block_Quickorder extends Mage_Core_Block_Abstract
{

}

我期待“Hello”显示在页面中间。相反,我一无所获。我知道布局的某些部分正在工作,因为当我导航到快速订购时,我得到了

<body class="quickorder-index-index">

有人能指出我在哪里出错了吗?

提前感谢任何帮助/提示/指示: - )

1 个答案:

答案 0 :(得分:3)

我没有检查过你的所有代码,但是这个

class Test_Quickorder_Block_Quickorder extends Mage_Core_Block_Abstract
{

}

应该是这个

class Test_Quickorder_Block_Quickorder extends Mage_Core_Block_Template
{

}

如果您想要一个块来渲染模板,它需要是Mage_Core_Block_Template的继承,或者是{{1}}的继承。