0

我真的很喜欢 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>

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

4

1 回答 1

0

Content block is a container (that means that every block that you add to it will be automatically rendered) and that's why it worked for you.

On the other hand checkout.onepage.payment block is derived (over an abstract class that doesn't change anything) from Mage_Core_Block_Template and blocks derived from this class don't automatically render your content.

You will have to change payment block's phtml file so that it will include your block

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

or

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

and change your layout xml file to (note the as part):

<block type="core/text_list" name="rrtest_list" as="rrtest_list_alias"/>
于 2013-01-29T08:21:06.377 回答