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.
The learning curve was kind of steep. I was banging my head against the wall and wondered why can’t the Magento team build the Admin panel in a similar fashion. I theorize maybe their team members had been fighting over different software architectures, and the Adminhtml was the result of a compromise.
This is pretty much a trade-off between the flexibility of .phtml template and convenience of the widgets.
Keep in mind that many Admin panel blocks are narrowly defined and highly repetitive in contrast to frontend modules. So it makes a lot of sense to standardize the block and template into the widgets.
Practice makes perfect.