Php Magento块未加载
我正在Magento中构建我的第一个模块,并有几个与此过程相关的问题 在我尝试一个模块之前,我刚刚有了一个模板,并用此代码将其加载到Php Magento块未加载,php,xml,magento,Php,Xml,Magento,我正在Magento中构建我的第一个模块,并有几个与此过程相关的问题 在我尝试一个模块之前,我刚刚有了一个模板,并用此代码将其加载到app\design\frontend\rwd\default\layout\local.xml <?xml version="1.0"?> <layout version="0.1.0"> <default> <reference name="after_body_start">
app\design\frontend\rwd\default\layout\local.xml
<?xml version="1.0"?>
<layout version="0.1.0">
<default>
<reference name="after_body_start">
<block type="checkout/cart_sidebar" template="mgw/mwCartRebuild.phtml"/>
</reference>
</default>
</layout>
config.xmlapp\code\local\mgw\Cart\etc\config.xml
<config>
<global>
<modules>
<mgw_Cart>
<version>0.0.0</version>
</mgw_Cart>
</modules>
<blocks>
<mgw_Cart>
<class>mgw_Cart_Block_Modal_Cart</class>
</mgw_Cart>
</blocks>
<helpers>
<cart>
<class>mgw_Cart_Helper</class>
</cart>
</helpers>
</global>
</config>
<layout version="0.1.0">
<default>
<reference name="after_body_start">
<block type="cart/modal_cart"/>
</reference>
</default>
</layout>
<config>
<modules>
<mgw_Cart>
<active>true</active>
<codePool>local</codePool>
<depends />
</mgw_Cart>
</modules>
</config>
模块xmlapp\etc\modules\mgw\u Cart.xml
<config>
<global>
<modules>
<mgw_Cart>
<version>0.0.0</version>
</mgw_Cart>
</modules>
<blocks>
<mgw_Cart>
<class>mgw_Cart_Block_Modal_Cart</class>
</mgw_Cart>
</blocks>
<helpers>
<cart>
<class>mgw_Cart_Helper</class>
</cart>
</helpers>
</global>
</config>
<layout version="0.1.0">
<default>
<reference name="after_body_start">
<block type="cart/modal_cart"/>
</reference>
</default>
</layout>
<config>
<modules>
<mgw_Cart>
<active>true</active>
<codePool>local</codePool>
<depends />
</mgw_Cart>
</modules>
</config>
真的
地方的
现在无法加载我的模板。我已经检查了管理员,看看我的模块是否正在加载,它是否已列出。那么为什么我的模板不能加载呢
我的问题是:
- 我能像我尝试的那样扩展核心块吗
- 如何加载我的块/模板
<blocks>
<checkout>
<rewrite>
<cart_sidebar>PkgName_ModuleName_Block_YourClassThatOverrides</cart_sidebar>
</rewrite>
</checkout>
</blocks>
PkgName_ModuleName_Block_您的类覆盖
在上面的代码中,您声明要用新类重写checkout/cart_边栏块
这就是config.xml,现在要创建覆盖的类。在模块的块目录中,创建扩展/重写核心类的类文件.php:
<?php
class PkgName_ModuleName_Block_YourClassThatOverrides extends Mage_Checkout_Block_Cart_Sidebar {
// check for the methods to rewrite or create new methods
}
谢谢你,马可,这是很好的信息。学习magento 1有很多不完整的来源。很难把所有东西拼凑在一起。我很快就会尝试所有这一切。这很难,因为没有一个免费的直线指南可以遵循,就像他们做了explode(“,MagentoGuide1.x)
。只要坚持锻炼,你就会获得更多的知识。我很高兴解决了您的问题。在获取要加载的自定义块时仍然存在问题
,我可以让控制器加载块,但不能从此引用中加载。NVM。我想出来了。我的块类文件命名不正确。