childHtml块的确切位置意外结果

问题描述

| 我试图在另一个phtml页面中的特定位置放置一个新的phtml块,但没有得到预期的结果-任何建议将不胜感激。 具体来说,我在模块的xml布局文件中为购物车页面创建了一个新的childHtml块:
<layout version=\"0.1.0\">
    <checkout_cart_index>
        <reference name=\"head\">
            <action method=\"addJs\"><script>varien/product.js</script></action>
            <action method=\"addItem\"><type>js_css</type><name>calendar/calendar-win2k-1.css</name><params/><!--<if/><condition>can_load_calendar_js</condition>--></action>
            <action method=\"addItem\"><type>js</type><name>calendar/calendar.js</name><!--<params/><if/><condition>can_load_calendar_js</condition>--></action>
            <action method=\"addItem\"><type>js</type><name>calendar/calendar-setup.js</name><!--<params/><if/><condition>can_load_calendar_js</condition>--></action>
        </reference>
        <reference name=\"content\">
            <block type=\"delivery/frontend_checkout_cart_delivery\" name=\"delivery.container\" as=\"delivery\" template=\"unleaded/delivery/checkout/cart/shipping/delivery.phtml\"/>
            <block type=\"core/html_calendar\" name=\"delivery_html_calendar\" as=\"delivery_html_calendar\" template=\"page/js/calendar.phtml\"/>
        </reference>
    </checkout_cart_index>
</layout>
接下来,我在修改后的
checkout/cart/shipping.phtml
模板中调用
$this->getChildHtml(\'delivery\')
,在其中放置了它:
....
<?php foreach ($_shippingRateGroups as $code => $_rates): ?>
    ....
    <?php foreach ($_rates as $_rate): ?>
        ....
        <li>
        <?php if ($_rate->getCode() == \'delivery\'): ?>
            <?php echo $this->getChildHtml(\'delivery\'); ?>
        <?php endif; ?>
        </li>
        ....
    <?php endforeach; ?>
    ....
<?php endforeach; ?>
....
我想要/期望的是在块的插入位置看到我的块输出,但是却正在页面的最底部输出它(请参见屏幕截图)。我几乎可以确定我的错误是基于xml /布局的错误,但是我不知道是什么?     

解决方法

您从“ 5”块中调用“ 4”,但将新块添加到“ 6”。代替,
<reference name=\"content\">
...您只需要说出您的新块将是哪个块。
<reference name=\"checkout.cart.shipping\">
    

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...