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.

  • Where are you putting this xml? Also, are you sure that you have the correct block type? Should it say available instead of additional? – pspahn Nov 1 '13 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) – mpw Nov 5 '13 at 21:57
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!

  • Right. I no longer have a block named root, but instead a block with the alias root. – mpw Nov 5 '13 at 22:00
  • I don'T understand what you want to say with this. – Fabian Blechschmidt Nov 6 '13 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. – mpw Nov 6 '13 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. – Fabian Blechschmidt Nov 6 '13 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 :) – Fabian Blechschmidt Nov 7 '13 at 10:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.