Magento Backoffice (Admin Panel) Options - [Part 2]

Now, when you are a bit familiar with Magento "Admin Panel" options (see Magento Backoffice (Admin Panel) Options - [Part 1]), let's do something creative. You remember that the first part said that you can add your own menu entries? It's very useful if you want to control your module (of course the new menu entry doesn't have to manage a new module, it can be used to handle existing functionality as well). So - let's see how to do it.

First of all, you need to create a new module. Alternatively, you can download source code of a module which I created for the purpose of this article and to which I am going to refer. The module will display current time, and it's format will be set by you. The format should be a valid argument of PHP date() function.

Adding entry to menu takes place in config.xml file. What we need are the folowing lines:

<adminhtml>
    <menu>
        <example translate="title" module="adminhtml">
            <title>Set Time Format</title>
            <sort_order>60</sort_order>
            <children>
                <set_time>
                    <title>Set It!</title>
                    <action>example/index</action>
                </set_time>
            </children>
        </example>
    </menu>
</adminhtml>

This code will add entry labelled Set Time Format with subentry Set It! and it refers to module identified by example, controller index, action index. Basically, that's all that is necessary to put our new entry into the menu. Check the result in the backoffice - the new entry should appear between Catalog and Customers. If not - clear the cache.

The rest of the module are just files defining form used to enter time format and controller responsible for displaying the form or saving data. As you can see, I decided to store the data along with Magento config values. It was just a quick, dirty solution, to avoid creating more than what is essential in this short how-to.

You can also add your entry on System->Configuration page. It needs a bit diferent approach and this topic will be covered in the next part.

AttachmentSize
Example.zip9.56 KB

2 comments on "Magento Backoffice (Admin Panel) Options - [Part 2]"

Kiwy's picture
Kiwy (visitor) - Tue, 31/08/2010 - 14:07:

Bonjour,
Cela ne fonctionne pas chez moi, j'ai télécharger Example.zip, mis correctement, vérifié que le module est bien actif (C'est le cas) mais je n'ai aucun nouveau menu qui apparait.

Sauriez vous quel peut en être la cause?

Merci d'avance

Pawan's picture
Pawan (visitor) - Sat, 27/11/2010 - 12:03:

Hello Please any one can explain the folder structure where to put the code in the magento cms

I have download the whole code but not understand where it should be placed,

I have placed my code in app/code/local but it did not show any menu in admin panel. is it the right path or not.

please advice me,

Thanks.