Skip to main content
Bumped by Community user
Bumped by Community user
Bumped by Community user
improved formatting
Source Link
Qaisar Satti
  • 32.6k
  • 18
  • 88
  • 138

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/etc/modules/MG_Block.xml:

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>

<config> <modules> <MG_MyBlock> <active>true</active> <codePool>local</codePool> </MG_MyBlock> </modules> </config> 

app/code/local/MG/MyBlock/Block/Products.php:app/code/local/MG/MyBlock/etc/config.xml:

class MG_MyBlock_Block_Products extends Mage_Core_Block_Abstract{ public function index(){ return "hello world"; } }

<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/design/frontend/rwd/default/template/mg/products.phtml:app/code/local/MG/MyBlock/Block/Products.php:

<?php echo $this->index(); ?>

class MG_MyBlock_Block_Products extends Mage_Core_Block_Abstract{ public function index(){ return "hello world"; } } 

app/design/frontend/rwd/default/layout/local.xml:app/design/frontend/rwd/default/template/mg/products.phtml:

<?php echo $this->index(); ?> 

<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>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> 

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>

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> 
Source Link

Custom module does not display in page

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.