magentomaintainabilitycode-maintainability

How do I apply nonintrusive design changes to Magento 1.X


I am having a little trouble here with a Magento installation here, which I "inherited" from a company who did some pretty heavy customizations to the theme.

I tried to rationalize most of the changes and was pretty successful with it. The problem is now, that I have some template files which have only one line of change.

In this specific case for example it would be a <button> that is now an <a> link. This is pretty much only one line in a 300 line template file.

Similar problems occurred with layout files of extensions. They have ONE dirty line in there, which for example resets the whole layout. I then need to overwrite the complete layout XML file in the design, just to make a little change in one line, because those layout files are either overwritten or not. There is not merging process involved.

I took a look into the designer's documentation of Magento, but could not find anything useful. I know that I could do some specific layout changes in the "local.xml" in my design, but those are more or less "contextless", which is not that great if those changes do belong to a certain extension.

Do you know a way to apply little template changes like mentioned in the first half or partially layout file overrides?

My main goal is to keep the files automatically updatable, which pretty much means: Download the module, replace files, done. No manual updates to any overwritten files.


Solution

  • Use the "inherited" template as default template in a new package and add a child template with your changes. Example:

    app/design/frontend/[package_name]/default - here will be the "inherited" old template app/design/frontend/[package_name]/[your_child_template] - here will be your new child template

    skin/design/frontend/[package_name]/default - here will be the "inherited" old template skin/design/frontend/[package_name]/[your_child_template] - here will be your new child template

    Partially layout file overwrides can be done for all pages or extensions in one local.xml file. Example:

    app/design/frontend/[package_name]/[your_child_template]/layout/local.xml

    If you want to add changes for a certain extension just add the extension xml file in your template folder. It will be the last one rendered and will wthe original. Example for the checkout cart page:

    app/design/frontend/[package_name]/[your_child_template]/template/checkout/cart.phtml

    For a small change inside a phtml file like your button example you will have to overwrite the whole phtml file. There is no way in Magneto to overwrite just a part of a phtml file.