Magento Expert Forum - Improve your Magento experience

Results 1 to 3 of 3

Changing the Adminhtml template

  1. #1
    Administrator david's Avatar
    Join Date
    Nov 2012
    Posts
    261
    Thanks
    22
    Thanked 42 Times in 34 Posts

    Thumbs up Changing the Adminhtml template

    To change the AdminHTML Template or Theme, you will need to know how to override Magento’s core modules, and know how the templates in Magento work. This article assumes that you know how to do this. If you do not, please read the appropriate Wiki Articles on the subject before continuing.



    Creating a new template inside design/adminhtml/default/ and placing template files in the folder does not automatically override the default Magento backend theme, nor is there an option in Magento’s backend to change this theme.



    To correct this, we must manually instruct Magento that we want to change the selected theme, so that we can use our own template files. To do this, we are going to override a Magento block called Mage_Adminhtml_Block_Page and use our classes’ construct function to tell Magento that we want to use our own theme.



    [TR]

    [TD][/TD]
    [/TR]
    Copy The Class



    The class that we are going to be changing is located inmagento/app/code/core/Mage/Adminhtml/Block/Page.php. Create a the new folders required so that you have /magento/app/code/local/MyCompany/Adminhtml/Block/ available, and copy Page.php there. (MyCompany can be whatever you want, just make sure that it’s the same the entire time you are going through the steps in this article.)



    [TR]

    [TD][/TD]
    [/TR]
    Change The Class Name



    The next step is the change the class name. Right now your class name is Mage_Adminhtml_Block_Page, we are going to change it to MyCompany_Adminhtml_Block_Page. Those of you who have overridden Magento modules before know that we also need to change the class that our new class extends. We are going to do this, but rather than extend our original class, change the extending class to Mage_Adminhtml_Block_Template. Your class delaration should now read: class MyCompany_Adminhtml_Block_Page extends Mage_Adminhtml_Block_Template



    [TR]

    [TD][/TD]
    [/TR]
    Set The Theme


    Now that our class named correctly, we need to actually tell Magento what theme to use. We are going to run one of Magento’s core functions called setTheme, and we are going to tell it the name of the Theme we want the backend to use. This theme should be the foldername located in magento/app/design/adminhtml/ and will most likely be called MyCompany. To do this, empty out the class and enter this:

    1. class MyCompany_Adminhtml_Block_Page extends Mage_Adminhtml_Block_Template
    2. {
    3. public function __construct()
    4. {
    5. Mage::getDesign()->setTheme('MyCompany');
    6. }
    7. }





    [TR]

    [TD][/TD]
    [/TR]
    Activate The Class



    Open up magento/app/etc/local.xml. In this file we are going to tell Magento to use our new Class instead of the core class. You should already be familiar with how to do this, but if you are not, here is how:


    Locate the blocks section of the XML file, it should be located under config and then global. In it, enter the following:

    1. <adminhtml>
    2. <rewrite>
    3. <page>MyCompany_Adminhtml_Block_Page</page>
    4. </rewrite>
    5. </adminhtml>





    [TR]

    [TD][/TD]
    [/TR]
    Design Your Template


    Magento should now be looking in the correct folder the backend template files. The best place to start when creating a template for the backend is page.phtml, located inmagento/design/adminhtml/default/default/template/, and of course you know to copy the file tomagento/design/adminhtml/default/MyCompany/template/.

    View more threads in the same category:


  2. #2
    New member
    Join Date
    Mar 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    how to embed coding


    class MyCompany_Adminhtml_Block_Page extends Mage_Adminhtml_Block_Template
    {
    public function __construct()
    {
    Mage::getDesign()->setTheme('MyCompany');
    }
    }

  3. #3
    Moderator shunavi's Avatar
    Join Date
    Mar 2013
    Posts
    124
    Thanks
    9
    Thanked 26 Times in 17 Posts

    Default

    Quote Originally Posted by kingmagicl View Post
    how to embed coding
    It 's located in magento/app/code/core/Mage/Adminhtml/Block/Page.php

Similar Threads

  1. Replies: 0
    Last Post: 10-07-2013, 10:14 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •