我正在尝试从我的模块中的布局加载模板文件,但我的布局xml文件没有在config.xml中添加。我尝试了一些解决方案,但我不知道我在做什么错。请帮助我告诉我我错在哪里。我在下面添加了我的代码..
IndexController.php
<?php
class Magemodul_Test_IndexController extends Mage_Core_Controller_Front_Action
{
public function indexAction()
{
$this->loadLayout();
$this->renderLayout();
}
}
?>
config.xml中
<?xml version="1.0"?>
<config>
<modules>
<Magemodul_Test>
<version>1.0.0</version>
</Magemodul_Test>
</modules>
<frontend>
<routers>
<magemodultest>
<use>standard</use>
<args>
<module>Magemodul_Test</module>
<frontName>test</frontName>
</args>
</magemodultest>
</routers>
<layout>
<updates>
<magemodultest>
<file>test.xml</file>
</magemodultest>
</updates>
</layout>
</frontend>
<global>
<blocks>
<test>
<class>Magemodul_Test_Block</class>
</test>
</blocks>
</global>
</config>
阻止文件Monblock.php
<?php
class Magemodul_Test_Block_Monblock extends Mage_Core_Block_Template
{
public function methodblock()
{
return 'informations about my block !!' ;
}
}
layout xml file test.xml
<?xml version="1.0"?>
<layout version="0.1.0">
<test_index_index>
<reference name="content">
<block type="test/monblock" name="afficher_monbloc" template="test/afficher.phtml">
</reference>
</test_index_index>
</layout>
模板文件afficher.phtml
<?php
echo $this->getmethodblock();
?>