Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/246.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Magento块未加载_Php_Xml_Magento - Fatal编程技术网

Php 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">

我正在Magento中构建我的第一个模块,并有几个与此过程相关的问题

在我尝试一个模块之前,我刚刚有了一个模板,并用此代码将其加载到
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.xml
app\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>
模块xml
app\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>

真的
地方的
现在无法加载我的模板。我已经检查了管理员,看看我的模块是否正在加载,它是否已列出。那么为什么我的模板不能加载呢

我的问题是:

  • 我能像我尝试的那样扩展核心块吗
  • 如何加载我的块/模板

我是Magento的新手,我可以帮助您解决您的问题。 首先,我建议为您的自定义模块和文件使用一个清晰简单的命名法,“ModalCart.php”可以重命名为“ModalCart.php”,避免任何引用问题

如果要扩展/覆盖Mage类,需要在模块的config.xml中指定它,如下所示:

<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。我想出来了。我的块类文件命名不正确。