magento-nofrills阻止添加不起作用

时间:2013-01-29 04:37:29

标签: magento

我非常喜欢Alan Storm的书,但是经过16个小时的尝试后我仍然无法取得进步!

我有一个有效的付款方式,但我想在One Step Checkout中添加一个块来显示可用的付款方式。

第一步是进行基本测试......

如果我定位内容,我的测试文字会按预期显示:

<checkout_onepage_index>
        <reference name="content">
            <block type="core/text_list" name="rrtest_list"/>
        </reference>
        <reference name="rrtest_list">
            <block type="core/text" name="rrtest1">
                <action method="setText">
                    <text>ABCDEFGHIJ KLMNOPQRSTUVWXYZ *************</text>
                </action>
            </block>
        </reference>
</checkout_onepage_index>

但是,如果我瞄准我真正想要的块,它就不起作用了:

<checkout_onepage_index>
        <reference name="checkout.onepage.payment">
            <block type="core/text_list" name="rrtest_list"/>
        </reference>
        <reference name="rrtest_list">
            <block type="core/text" name="rrtest1">
                <action method="setText">
                    <text>ABCDEFGHIJ KLMNOPQRSTUVWXYZ *************</text>
                </action>
            </block>
        </reference>
</checkout_onepage_index>

什么都没有出现。为什么这不起作用?

1 个答案:

答案 0 :(得分:0)

内容块是一个容器(这意味着您添加到它的每个块都将自动呈现),这就是它为您工作的原因。

另一方面,checkout.onepage.payment块是从Mage_Core_Block_Template导出的(通过一个不会改变任何东西的抽象类),从这个类派生的块不会自动呈现你的内容。

您必须更改付款块的phtml文件,以便它包含您的块

<?php echo $this->getChildHtml( 'rrtest_list_alias' ); // this outputs the html directly ?>

<?php echo $this->getChild( 'rrtest_list_alias' )->myFunctions()->toHtml(); // this allows you to call some functions on your block and then outputs the html ?>

并将布局xml文件更改为(注意作为部分):

<block type="core/text_list" name="rrtest_list" as="rrtest_list_alias"/>