Luis Valencia
Luis Valencia

Reputation: 33978

Is it local.xml the right location for my layout update? Or should I create another file?

I have added the following code in local.xml

<checkout_onepage_success>
    <reference name="head">
        <block type="core/template" name="cj_udo" template="cj/udo.phtml" />
    </reference>
</checkout_onepage_success>

on /app/design/frontend/base/default/layout/local.xml

Is this the right place, or should be separated?

What does it mean base folder? it means it applies to all themes and if I change theme it will continue working

Upvotes: 1

Views: 116

Answers (2)

Alana Storm
Alana Storm

Reputation: 166046

It depends on who you are.

If you're a Magento system owner, or working on a specific system for a Magento system owner, local.xml is the right place for your layout updates.

However, if you're a module developer creating code you want to port to many different systems, then the correct thing to do would be

  1. Create a new module

  2. Add a layout update XML file (namespace_module.xml) to the config.xml for your module

  3. Add this layout update XML file to app/design/frontend/base/default/layout/namespace_module.xml

Upvotes: 1

jzahedieh
jzahedieh

Reputation: 1579

If you are working on a theme, it is debatable but it is fine to update the layout file local.xml in your custom theme.

If you are working on a module, you should define a custom layout file, something like namespace_module.xml I prefer namespace/module.xml though. Even if you are theming, it is best to create a new module so you can define you custom xml anyway.

Under no circumstance should you directly modify core files, eg /app/design/frontend/base/default/layout/local.xml. app/code/core, etc..

I think you need to research best practice development more, good start is http://magentotherightway.com/.

Upvotes: 1

Related Questions