Archive for 2008

Magento Admin panel: Adminhtml

Monday, December 15th, 2008 by

The Magento Admin panel is controlled by the Adminhtml module. And all Adminhtml pages require validation/authentication.

In fact, Magento has different ways treating GET and POST  admin pages, i.e.: $secretKey vs. ‘form_key’

magento admin panel

(This is a developer’s guide.)

For GET request, we must provide http:// … /id/’secretKey’
For POST request, we must provide ‘form_key’ as a post parameter.

Example for GET:  simple attach to the end of the URL in the block .php, note that the secret key only involves the controller and the action, not the module name.

[codesyntax lang="php" lines="fancy"]

public function getSearchResultGetUrl(){
    //must pass on the key to maintain logged in
    $secretKey = Mage::getSingleton('adminhtml/url')->getSecretKey('adminhtml_search', 'result');
    return Mage::getUrl('pet/adminhtml_search/result/key/'.$secretKey);



Magento Adminhtml, a Widget Heavy Approach

Monday, November 10th, 2008 by


Magento Adminhtml, a Widget Heavy Approach

After 5  custom modules, I started to feel comfortable coding with Magento and picked up my coding speed. And then came the first project with massive modifications in the Admin panel, i.e. Adminhtml module. I had to admit that I totally underestimated the complexity of the task. The Adminhtml is, well, very different.

A common frontend module usually has an exact mapping between the actions in the controller and the views (block .php file plus template .phtml file), as defined in the layout file. Basically I can begin with the action in the controller, then use the layout .xml to look up the template .phtml files, and the outline of the code is clear.

However, such strict mapping is absent in the Adminhtml module, whose blocks are often directly controlled by the PHP code and also heavily rely on the block widgets.

I took a couple of days to investigate the source code, despite some remaining grudge against this ‘free-form’ module. I found the block widgets quite convenient.
There are many nice widgets like: Mage_Adminhtml_Block_Widget_Form, …_Grid, and etc.