0

In attempting to avoid rewriting the Mage_Checkout_Block_Onepage_Shipping_Method_Additional block, I've been following my current strategy of removing the block with the old class and adding a new one with my new class:

<checkout_onepage_shippingmethod>
  <remove name="root" />
  <block type="my_checkout/onepage_shipping_method_additional" name="my.root" as="root" output="toHtml" template="checkout/onepage/shipping_method/available.phtml" />
</checkout_onepage_shippingmethod>

This works great for non-root blocks, but my alias technique doesn't seem to work in this case. Any ideas?

PS: I'm aware that this can be done with a rewrite.

2
  • Where are you putting this xml? Also, are you sure that you have the correct block type? Should it say available instead of additional? Commented Nov 1, 2013 at 21:58
  • You're correct. I had a typo when transcribing the snippet into this question (I changed some module names to protect the privacy of clients) Commented Nov 5, 2013 at 21:57

1 Answer 1

2

I can't believe, this is working.

<remove> is the last statement processed before toHtml. This means, there is NO WAY to have a block with the name root when you remove it.

Bu you can just change the type of root by overriding the block, like in <checkout_onepage_shippingmethod> in /app/design/frontend/base/default/layout/checkout.xml:373

<checkout_onepage_shippingmethod>
    <!-- Mage_Checkout -->
    <remove name="right"/>
    <remove name="left"/>

    <block type="checkout/onepage_shipping_method_available" name="root" output="toHtml" template="checkout/onepage/shipping_method/available.phtml"/>
</checkout_onepage_shippingmethod>

It is totally great, that you avoid rewrites!

8
  • Right. I no longer have a block named root, but instead a block with the alias root. Commented Nov 5, 2013 at 22:00
  • I don'T understand what you want to say with this. Commented Nov 6, 2013 at 12:46
  • When getChild is called, a block with a matching name or as will be returned. However, it appears that whatever loads the root block requires the name. Commented Nov 6, 2013 at 13:37
  • it depends on the context. in the child context you have to use the alias (I think alias is set exactly the same when no alias is defined). When you are in a global context, like with <reference> you have to use the name. But I still don't understand how this is connected with your problem. Commented Nov 6, 2013 at 13:38
  • 2
    I'm sorry but I answer when I have time. When I should answer when you want it, you have to hire me :) Commented Nov 7, 2013 at 10:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.