My home.phtml file
echo $this->getLayout()->createBlock('banner/Monblock')
->setTemplate('banner/afficher.phtml')->toHtml();
my layout file.
<?xml version="1.0" ?>
<layout version="0.1.0">
<test_adminhtml_index_index>
<reference name="content">
<block type="banner/Myblock" name="afficher_monbloc"
template="banner/afficher.phtml"/>
<block type="banner/adminhtml_grid" name="banner" />
</reference>
</test_adminhtml_index_index>
<reference name="content">
<block type="banner/Monblock" name="afficher_monbloc"
template="banner/afficher.phtml"/>
<block type="banner/adminhtml_grid" name="banner" />
</reference>
<default>
<reference name="content">
</reference>
</default>
<banner_index>
<reference name="content">
<block type="banner/Monblock" name="afficher_monbloc"
template="banner/afficher.phtml"/>
<block type="test/test" name="test"
template="test/tes2.phtml" />
</reference>
</banner_index>
</layout>
My block file
class Banner_Banner_Block_Monblock extends Mage_Core_Block_Template
{
public function methodblock()
{
return 'informations about my block !!' ;
}
}
config.xml
<?xml version="1.0"?>
<config>
<modules>
<Banner_Banner>
<version>1.0.0</version>
</Banner_Banner>
</modules>
<frontend>
<routers>
<banner>
<use>standard</use>
<args>
<module>Banner_Banner</module>
<frontName>banner</frontName>
</args>
</banner>
</routers>
<layout>
<updates>
<Banner_Banner>
<file>Banner.xml</file>
</Banner_Banner>
</updates>
</layout>
</frontend>
<admin>
<routers>
<banner>
<use>admin</use>
<args>
<module>Banner_Banner</module>
<frontName>admintest</frontName>
</args>
</banner>
</routers>
</admin>
<adminhtml>
<layout>
<updates>
<banner>
<file>banner.xml</file>
</banner>
</updates>
</layout>
<menu>
<banner translate="title" module="adminhtml">
<title>My Banner</title>
<sort_order>100</sort_order>
<children>
<set_time>
<title>Add Banner</title>
<action>admintest/adminhtml_index</action>
</set_time>
</children>
</banner>
</menu>
</adminhtml>
<global>
<models>
<banner>
<class>Banner_Banner_Model</class>
<resourceModel>Banner_mysql4</resourceModel>
</banner>
<banner_mysql4>
<class>Banner_Banner_Model_Mysql4</class>
<entities>
<banner>
<table>banner</table>
</banner>
</entities>
</banner_mysql4>
</models>
<!-- allow the plugin to read and write -->
<resources>
<!-- connection to write -->
<test_write>
<connection>
<use>core_write</use>
</connection>
</test_write>
<!-- connection to read -->
<test_read>
<connection>
<use>core_read</use>
</connection>
</test_read>
</resources>
<!-- -/- -->
<blocks>
<Banner>
<class>Banner_Banner_Block</class>
</Banner>
</blocks>
</global>
</config>
config.xml
file of your module?