Php 我在magento 1.9上的重写块不';行不通
你好,我是Magento的新手,我试着重写我的区块 我的剧本是这样的: app/etc/modules/Lesson2_all.xmlPhp 我在magento 1.9上的重写块不';行不通,php,xml,magento,url-rewriting,Php,Xml,Magento,Url Rewriting,你好,我是Magento的新手,我试着重写我的区块 我的剧本是这样的: app/etc/modules/Lesson2_all.xml <?xml version="1.0"?> <config> <modules> <Lesson2_Test> <active>true</active> <codePool>local</codePo
<?xml version="1.0"?>
<config>
<modules>
<Lesson2_Test>
<active>true</active>
<codePool>local</codePool>
<depends><Mage_Catalog /></depends>
</Lesson2_Test>
</modules>
</config>
我的布局和模板位于:
app/design/frontend/rwd/default/layout/lesson2.xml
<layout version="0.1.0">
<default>
<reference name="content">
</reference>
</default>
<lesson2_index_index>
<reference name="content">
<block type="lesson2/monblock" name="afficher_monbloc" template="lesson2/afficher.phtml" />
</reference>
</lesson2_index_index>
</layout>
app/design/frontend/rwd/default/template/lesson2/afficher.phtml
<?php
echo $this->methodblock();
?>
如果我运行这个脚本localhost/magento/lesson2,我看不出发生了什么,我只看到一条消息:“关于我的块的信息!!”(这是我的默认块)
谢谢,如果我理解错了,很抱歉。如果您转到
localhost/magento/lesson2/index/index
它能工作吗?另外,请在config.xml中的..
内
共享代码,因为该文件不应包含该代码,app/etc/modules/Lesson2_all.xml
应与您的模块名称匹配,例如app/etc/modules/Lesson2_Test.xml
谢谢@RobbieAverill yes仍然不起作用,这是config.xml1.0.0
status Lesson2\u测试系统输出的模块->高级中的我的代码已启用这是`标准Lesson2\u测试Lesson2'中的我的代码lesson2.xml`他的错误可能是在我的新街区吗?是否只有Mage才能调用模型/资源的重写,例如Mage::getModel()、Mage::getResourceModel()、Mage::Helper()、Mage::getSingletonBlock()
?
<?php
class Lesson2_Test_Block_Monblock extends Mage_Core_Block_Template
{
public function methodblock()
{
return 'informations about my block !!' ;
}
}
<?php
class Lesson2_Test_Block_Catalog_Product_View extends Mage_Catalog_Block_Product_View
{
public function productView()
{
return 'skuycesiu';
}
}
<layout version="0.1.0">
<default>
<reference name="content">
</reference>
</default>
<lesson2_index_index>
<reference name="content">
<block type="lesson2/monblock" name="afficher_monbloc" template="lesson2/afficher.phtml" />
</reference>
</lesson2_index_index>
</layout>
<?php
echo $this->methodblock();
?>