Create your own Backend theme

When developing Magento Backend functionalities, sometimes you need to add own layout files or templates. In these cases it is a good idea to create a new Backend theme under adminhtml and to modify the Magento configuration to lookup layout files and templates in this new theme before searching in the default one.

Therefore you have to create a folder structure like that under design/adminhtml:

  • app/design/adminhtml/default/themename/
    • layout
      • namespace_module.xml
    • template
      • namespace_module
        • path
          • to
            • template
              • phtml

Afterwards you can register your own theme in any modules config.xml like that:

<?xml version="1.0"?>
<config>

...

<!-- change admin theme -->
    <stores>
        <admin>
            <!-- default admin design package and theme -->
            <design>
                <package>
                    <name>default</name>
                </package>
                <theme>
                    <default>themename</default>
                    <default_theme>default</default_theme>
                </theme>
            </design>
        </admin>
    </stores>

...

</config>

But there is one thing left to do. You have to tell Magento, that your module has  layout updates for the Backend:

<?xml version="1.0"?>
<config>

...
    <adminhtml>
        <layout>
            <updates>
                <namespace_module>
                    <file>namespace_module.xml</file>
                </namespace_module>
            </updates>
        </layout>
    </adminhtml>   

...

</config>

Now you can add templates and layout updates to your own theme. Magento will search for layout- and template files in your theme now.  All files not found in your theme structure will be searched in the default theme.

Leave a Reply

Your email address will not be published. Required fields are marked *

 

This site uses Akismet to reduce spam. Learn how your comment data is processed.