Magento Block construct - use _construct or __construct?

magento, magento-1.7

Solution

It's ultimately academic, but the Right Way To Do It® is to override the Magento constructor i.e. `_construct` as requested by the core team in `Mage_Core_Block_Abstract`:

/**
 * Internal constructor, that is called from real constructor
 *
 * Please override this one instead of overriding real __construct constructor
 *
 */
protected function _construct()
{
    /**
     * Please override this one instead of overriding real __construct constructor
     */
}

Problem

I am a little bit confused. I read Alan Storm's excellent article about Magento Block Lifecycle Methods and as far as I understand one should be using the `protected _construct()` method to initialize the block. In my case I just want to set the right block template. So I assume I should be using ``` protected function _construct() { parent::_construct(); $this->setTemplate('stenik/qaforum/forum.phtml'); } ``` However, when I look at the blocks of some of the core Magento modules, they seem to use the php __construct method to do it. For example `Mage_Poll_Block_Poll`, `Mage_ProductAlert_Block_Price`, `Mage_Rating_Block_Entity_Detailed`, `Mage_Review_Block_Form` Although both ways actually work, I'd like to know what is the right way to do it.

Original source