glenelkins Posted July 10, 2009 Share Posted July 10, 2009 Hi I dont know whats going on with these modules. Im writing a test one called HelloWorld. But the only output i ever seem to get is through _toHtml() function inside the block ?? In the layout config xml i have this: <?xml version="1.0"?> <layout version="0.1.0"> <helloworld_index_index> <reference name="root"> <action method="setTemplate"><templates>page/1column.phtml</templates></action> </reference> <reference name="content"> <block type="helloworld/helloworld" name="hello" templates="helloworld/helloworld.phtml" /> </reference> </helloworld_index_index> </layout> The file “helloworld/helloworld.phtml” has the content “Hello World!” but it never loads up, here is the IndexController followed by the HelloWorld block <?php class M4U_HelloWorld_IndexController extends Mage_Core_Controller_Front_Action { public function indexAction() { $this->loadLayout(); $this->renderLayout(); } } ?> <?php class M4U_HelloWorld_Block_HelloWorld extends Mage_Core_Block_Template { function _toHtml() { return "HELLO"; } } ?> All the block seems to do is load the block template file and insert what is returned from _toHtml() if i dont have this function, then nothing gets displayed! Here is the module config.xml <?xml version="1.0"?> <config> <global> <modules> <m4u_helloworld> <version>0.1.0</version> </m4u_helloworld> </modules> <blocks> <helloworld> <rewrite> <helloworld>M4U_HelloWorld_Block_HelloWorld</helloworld> </rewrite> </helloworld> </blocks> </global> <frontend> <routers> <helloworld> <use>standard</use> <args> <module>M4U_HelloWorld</module> <frontName>helloworld</frontName> </args> </helloworld> </routers> <layout> <updates> <helloworld> <file>helloworld.xml</file> </helloworld> </updates> </layout> </frontend> </config> Link to comment https://forums.phpfreaks.com/topic/165459-magento-module-developmenthellworld/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.