Create custom block types

In the layout xml like this:
[geshifilter-xml]<layout> <translationexporter_index_index> <reference name="content"> <block type="core/template" name="translationexporter_index" template="translationexporter/index.phtml" /> </reference> </translationexporter_index_index> </layout>[/geshifilter-xml]

Given the type 'core/template' means showing the template file directly, without using block. The example above will show the template file in app/design/adminhtml/default/default/template/translationexporter/index.phtml. As we have the following settings in etc/config.xml.
[geshifilter-xml] <adminhtml> <layout> <updates> <translationexporter> <file>translationexporter.xml</file> </translationexporter> </updates> </layout> </adminhtml>[/geshifilter-xml]

If we want to have a custom block to deal with programming logic. We could modify block type first.
[geshifilter-xml]<block type="translationexporter/index" name="translationexporter_index" template="translationexporter/index.phtml" />[/geshifilter-xml]

Then we must register the name space "translationexporter" for blocks. Add the following settings to etc/config.xml.
[geshifilter-xml] <blocks> <translationexporter> <class>Namespace_TranslationExporter_Block</class> </translationexporter> </blocks>[/geshifilter-xml]

Finally add the the block code to Namespace/TranslationExporter/Block/Index.php
[geshifilter-php]<?php class Namespace_TranslationExporter_Block_Index extends Mage_Core_Block_Template { public function getHi() { return 'hello'; } }[/geshifilter-php]

Now you could move programming logic, like get data from model, to the block. It could make the template file cleaner and more friendly for designers.

English