I'm trying to add custom block module to homepage but it does not load my block.phtml file. Here are my files: app/etc/modules/MG_Block.xml:
<config> <modules> <MG_MyBlock> <active>true</active> <codePool>local</codePool> </MG_MyBlock> </modules> </config> app/code/local/MG/MyBlock/etc/config.xml:
<config> <modules> <MG_MyBlock> <version>0.1.0</version> </MG_MyBlock> </modules> <global> <blocks> <mg_myblock> <class>MG_MyBlock_Block</class> </mg_myblock> </blocks> </global> </config>` app/code/local/MG/MyBlock/Block/Products.php:
class MG_MyBlock_Block_Products extends Mage_Core_Block_Abstract{ public function index(){ return "hello world"; } } app/design/frontend/rwd/default/template/mg/products.phtml:
<?php echo $this->index(); ?> app/design/frontend/rwd/default/layout/local.xml:
<layout version="0.1.0"> <default> <reference name="content"> <block type="mg_myblock/products" output="toHtml" name="myblock" template="mg/products.phtml" after="-" /> </reference> </default> </layout> When I use var_dump in _construct() function in my block it shows var_dump but it does not load template file.
Mage_Core_Block_Templateinstead ofMage_Core_Block_Abstractand it works.