开发者

Exact Placement of childHtml Block (unexpected result)

I am trying to place a new phtml block at a specific place within another phtml page and I am not getting the results I expected - any advice would be much appreciated.

Specifically, I created a new childHtml block for the cart page in my module's xml layout file:

<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/j开发者_运维技巧s/calendar.phtml"/>
        </reference>
    </checkout_cart_index>
</layout>

Next I made a call to $this->getChildHtml('delivery') in my modified checkout/cart/shipping.phtml template where I wanted it placed:

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

What I wanted / expected was to see my block output where I inserted it, but instead it is being output at the very bottom of the page (see screenshot). I am almost certain my mistake is an xml / layout based mistake, but I don't know what?

Exact Placement of childHtml Block (unexpected result)


You call getChildHtml() from within the checkout.cart.shipping block, but add your new block to content. Instead of,

<reference name="content">

...you simply need to say which block your new one will be the child of.

<reference name="checkout.cart.shipping">
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜