This is a basic question, but which drove me sleepless for the past a few days.
I wrote a customized module with a controller, a phtml template and a block class as below: app/code/local/Huahan/HelloWorld/Block Helloworld.php (where Huahan_Helloworld_Block_Helloworld extends Mage_Core_Block_Template) app/code/local/Huahan/HelloWorld/controllers IndexController.php (where indexAction of index controller is defined) app/design/frontend/base/default/template/huahan/helloworld helloworld.phtml (where view is defined) app/design/frontend/base/default/layout helloworld.xml (the filename "helloworld.xml" is specified in etc/config.xml)
I know that every request handling in Magento starts from a controller and its action method.
In the layout helloworld.xml, I specifies the template file in the block tag
<helloworld_index_nihao>
<block type="core/template" name="just_an_arbitary_name" output="toHtml" template="huahan/helloworld/nihao.phtml"/>
</helloworld_index_nihao>
</layout>
So the controller knows which template to use while handling request.
The problem is how I can let Magento know that Huahan_Helloworld_Block_Helloworld is the block class I want it to load before rendering any output?
And if there is any detailed documentation about the Magento xml? I am always frustrated by the complex and arbitrariness of the Magento xml syntax
The version of Magento is ver.1.9.0.1
The config.xml is as below
<?xml version="1.0"?>
<config>
<modules>
<huahan_helloworld>
<version>
0.1.0
</version>
</huahan_helloworld>
</modules>
<frontend>
<routers>
<!-- the <helloworld> tagname appears to be arbitrary, but by
convention is should match the frontName tag below-->
<helloworld>
<use>standard</use>
<args>
<module>Huahan_HelloWorld</module>
<frontName>helloworld</frontName>
</args>
</helloworld>
</routers>
<layout>
<updates>
<helloworld>
<file>helloworld.xml</file>
</helloworld>
</updates>
</layout>
</frontend>
<global>
<blocks>
<helloworld>
<class>Huahan_Helloworld_block</class>
</helloworld>
</blocks>
</global>
</config>
Thanks in advance. I really appreciate that you read it down here.