tags:

views:

184

answers:

2

Hi,

I'm kind of new to the Magento, so forgive me for my stupid question! As I understand the whole concept of Magento is base on overriding the basic components that's are available with in the Magento.

So based on my understanding I've decided to update the layout of onepage checkout in Magento. I've created my own layout and in the config file set that my layout updates the checkout module layout. But the problem is it's actually does not update the base layout, it replaces it self with base layout! Should it be act like this or am I wrong?!

A: 

I think it depends on how you name your layout. If you named it checkout.xml, I think it will replace itself with the base layout. It you choose another name, I think it should override only the parts you specified. EDIT : Do not forget to clear your cache. And by the way, how do you know the xml file is actually replaced? The best way to know this might be to inspect your cache after it is regenerated.

greg0ire
As far as I tested it, it didn't depend on the name of the file! because even when I changed the name to mytest.xml and set the path inside the config file, still it replaced the whole layout!
Farid
I edited my post, but now I can add comments, did you see what I wrote?
greg0ire
+3  A: 

In fact, the node in your config.xml file doesn't do an "update". As a matter of fact, I think you have done that in your config.xml :

<config>
    <frontend>
        <layout>
             <updates>
                  <checkout>
                        <file>mylayout.xml</file>
                  </checkout>
             </updates>
        </layout>
    </frontend>
</config>

and you have done your modifications in mylayout.xml.

In fact, you have to do :

<config>
    <frontend>
        <layout>
             <updates>
                  <mymodule>
                        <file>mylayout.xml</file>
                  </mymodule>
             </updates>
        </layout>
    </frontend>
</config>

And then, in mylayout.xml :

<checkout_cart_index> <!-- this corresponds to the section where you want to add your block (or modify an existing block -->
       <reference name="content">
            <reference name="checkout.cart">
                <block type="mymodule/myblock" name="checkout.mymodule.myblock"></block>
            </reference>
        </reference>
</checkout_cart_index>

By looking at my code and comparing the files to each other, you will understand better how it works.

In fact, don't forget that all xml files are concatenated in magento. So that, all nodes in all config files, respecting the same order, will be concataneted.

For example, in our case, the config.xml files of magento will be concatenated, and the result is ONE file containing :

<config>
<!-- some nodes... -->
<!-- some nodes... -->
<!-- some nodes... -->
    <frontend>
        <layout>
             <updates>
                  <mymodule>
                        <file>mylayout.xml</file>
                  </mymodule>
                  <checkout> <!-- this is the node from the config.xml of the Checkout Module-->
                        <file>checkout.xml</file>
                  </checkout>
                  <!-- some layout updates nodes from other config files... -->
             </updates>
        </layout>
    </frontend>
<!-- some nodes... -->
<!-- some nodes... -->
</config>

If you had replaced <mymodule> by <checkout> the resulting file would have looked :

<config>
<!-- some nodes... -->
<!-- some nodes... -->
<!-- some nodes... -->
    <frontend>
        <layout>
             <updates>
                  <checkout>
                        <file>mylayout.xml</file>
                  </checkout>
                  <!-- some layout updates nodes from other config files... -->
             </updates>
        </layout>
    </frontend>
<!-- some nodes... -->
<!-- some nodes... -->
</config>

Note the mylayout.xml. This is the reason why the original layout file is completely replaced by your own layout :)

Hope that's clear, in french it would have been easier for me to explain ;)

Hugues.

Hugues ALARY
I think you explained it well in english, even the cow can understand your explanation :D! Thanks for your amazingly complete response.
Farid