tags:

views:

300

answers:

1

Hi,

I've created my own magento module and successfully extending core controllers and models but I'm having trouble doing the same with the layout xml files. I want to update just the checkout multishipping shipping page. So far I've only managed to to overwrite the entire checkout.xml file but I would much prefer to just have the in my xml file.

This is what i have in my modules config.xml and the tm.xml file is in app/design/frontend/default/default/layout/

<frontend>
        <layout>
            <updates>
                    <checkout>
                      <file>tm.xml</file>
      </checkout>
     </updates>
    </layout>
</frontend>

Thanks

+1  A: 

First, you may want to consider placing your layout file somewhere in your module. I'm not sure how widespread the practice is, but it makes sense from distribution point of view. It also ensures your layout overrides will apply, even if someone changes the theme from default. Doing something like this should work

<file>../../../../../code/local/Packagename/Modulename/layouts/tm.xml</file>

Second, as you've noted, with your XML above you're completely replacing checkout.xml in your magento install. You don't want to do this. Instead, you want to add your layout updates (the contents of that XML file) to Magento's list of available updates. So do something like this instead.

<layout>
 <updates>
  <my_package_my_module_name>                  
   <file>../../../../../code/local/Packagename/Modulename/layouts/tm.xml</file>
  </my_package_my_module_name>
 </updates>
</layout>

The big change here is we've changed <checkout> to be <my_package_my_module_name>. Magento loads all the XML specified in this section into something called a package layout. So with this, your XML will be living alongside the XML in checkout.xml.

In tm.xml, you'll setup your specific rules for multi-shipping

<layout version="0.1.0">
 <checkout_multishipping>
  <!-- ... -->
 </checkout_multishipping>

 <checkout_multishipping_login>
  <!-- ... -->
 </checkout_multishipping_login>
</layout>

The big thing to keep in mind here is, the existing rules in checkout.xml for multi-shipping will still exist. You'll need to write <reference /> rules to override what those rules are doing. This is how Magento's layout system works. I'd recommend looking over the Magento Designer's Guide if you haven't already, particularly the Intro to Layouts section.

One final note, you mentioned you're overriding controllers. If you're verriding the multi-shipping controller, you'll need to use <checkout_multishipping> tags, you'll need to use tags that match the name of the action controller/action method combination for that page on your controller

<packagename_modulename_actioncontrollername_action />
Alan Storm