Magento - 插件覆盖local.xml块

时间:2013-09-03 17:31:16

标签: magento

我有一个local.xml文件,其中包含以下内容:

<default>
   <cms_index_index translate="label">
      <reference name="masthead">
          <block type="page/html" template="cms/masthead/homepage.phtml" as="banners" />
      </reference>
   </cms_index_index translate="label">
</default>

我有一个拥有自己的config.xml的插件 - 我希望使用位于以下位置的模板覆盖上面的块:/app/code/local/MageWorx/GeoIP/cms/homepage.phtml。

然而,config.xml文件是不同的,如下所示:

<config>
<modules>
    <MageWorx_GeoIP>
        <version>1.0.7</version>
    </MageWorx_GeoIP>
</modules>

<frontend>
    <translate>
        <modules>
            <MageWorx_GeoIP>
                <files>
                    <default>MageWorx_GeoIP.csv</default>
                </files>
            </MageWorx_GeoIP>
        </modules>
    </translate>
    <routers>
        <geoip>
            <use>standard</use>
            <args>
                <module>MageWorx_GeoIP</module>
                <frontName>geoip</frontName>
            </args>
        </geoip>
    </routers>
    <layout>
        <updates>
            <geoip>
                <file>geoip.xml</file>
            </geoip>
        </updates>
    </layout>
    <events>
        <controller_action_predispatch>
            <observers>
                <geoip>
                    <type>singleton</type>
                    <class>MageWorx_GeoIP_Model_Observer</class>
                    <method>geoipAutoswitcher</method>
                </geoip>
            </observers>
        </controller_action_predispatch>
        <controller_action_predispatch_directory_currency_switch>
            <observers>
                <geoip>
                    <type>singleton</type>
                    <class>MageWorx_GeoIP_Model_Observer</class>
                    <method>setCurrency</method>
                </geoip>
            </observers>
        </controller_action_predispatch_directory_currency_switch> 
    </events>
</frontend>

<global>
    <models>
        <geoip>
            <class>MageWorx_GeoIP_Model</class>
            <resourceModel>geoip_mysql4</resourceModel>
        </geoip>
        <geoip_mysql4>
            <class>MageWorx_GeoIP_Model_Mysql4</class>
        </geoip_mysql4>
        <core>
            <rewrite>
                <store>MageWorx_GeoIP_Model_Core_Store</store>
            </rewrite>
        </core>
    </models>
    <resources>
        <geoip_setup>
            <setup>
                <module>MageWorx_GeoIP</module>
                <class>MageWorx_GeoIP_Model_Mysql4_Setup</class>
            </setup>
            <connection>
                <use>core_setup</use>
            </connection>
        </geoip_setup>
        <geoip_write>
            <connection>
                <use>core_write</use>
            </connection>
        </geoip_write>
        <geoip_read>
            <connection>
                <use>core_read</use>
            </connection>
        </geoip_read>
    </resources>
    <blocks>
        <geoip>
            <class>MageWorx_GeoIP_Block</class>
        </geoip>
        <adminhtml>
            <rewrite>
                <sales_order_view_info>MageWorx_Adminhtml_Block_Geoip_Adminhtml_Sales_Order_View_Info</sales_order_view_info>
                <customer_online_grid>MageWorx_Adminhtml_Block_Geoip_Adminhtml_Customer_Online_Grid</customer_online_grid>
                <system_store_edit_form>MageWorx_Adminhtml_Block_Geoip_Adminhtml_System_Store_Edit_Form</system_store_edit_form>
            </rewrite> 
        </adminhtml>
        <checkout>
            <rewrite>
                <onepage_billing>MageWorx_GeoIP_Block_Checkout_Onepage_Billing</onepage_billing>
                <onepage_shipping>MageWorx_GeoIP_Block_Checkout_Onepage_Shipping</onepage_shipping>
            </rewrite>
        </checkout>
        <customer>
            <rewrite>
                <address_edit>MageWorx_GeoIP_Block_Customer_Address_Edit</address_edit>
            </rewrite>
        </customer>
    </blocks>
    <helpers>
        <geoip>
            <class>MageWorx_GeoIP_Helper</class>
        </geoip>
    </helpers>
</global>

<adminhtml>
    <acl>
        <resources>
            <all><title>Allow Everything</title></all>
            <admin>
                <children>
                    <system>
                        <children>
                            <config>
                                <children>
                                    <mageworx_customers translate="title" module="mageworx">
                                    <title>MageWorx &gt; Customers</title>
                                    <sort_order>1</sort_order> 
                                        <children>
                                            <geoip translate="title" module="geoip">
                                                <title>GeoIP Location</title>
                                            </geoip>
                                        </children>
                                    </mageworx_customers>
                                </children>
                            </config>
                        </children>
                    </system>
                </children>
            </admin>
        </resources>
    </acl>
    <layout>
        <updates>
            <geoip>
                <file>geoip.xml</file>
            </geoip>
        </updates>
    </layout>
</adminhtml>

<default>
    <mageworx_customers>
        <geoip>
            <enable_store_switcher>1</enable_store_switcher>
            <enable_currency_switcher>1</enable_currency_switcher>
            <force_store_view>1</force_store_view>
            <store_switcher_scope>1</store_switcher_scope>
            <disable_store_switcher_key>off</disable_store_switcher_key>
            <store_switcher_exception_urls>/paypal/*</store_switcher_exception_urls>
            <db_type>1</db_type>
            <db_path>lib/GeoIP/GeoIP.dat</db_path>
            <enable_billing_country>1</enable_billing_country>
            <enable_shipping_country>1</enable_shipping_country>
            <enable_address_country>1</enable_address_country>
        </geoip>
    </mageworx_customers>
</default>

有没有人知道我应该在config.xml中添加哪些内容以及覆盖local.xml块?

1 个答案:

答案 0 :(得分:1)

您不能使用local.xml覆盖任何块或操作到config.xml

这里是magento的真相

config.xml和local.xml与您放在app / local中的任何其他xml文件一起加载。它们加载在Mage_Core_Model_Config::loadBase()

public function loadBase()
    {
        $etcDir = $this->getOptions()->getEtcDir();
        $files = glob($etcDir.DS.'*.xml');
        $this->loadFile(current($files));
        while ($file = next($files)) {
            $merge = clone $this->_prototype;
            $merge->loadFile($file);
            $this->extend($merge);
        }
        if (in_array($etcDir.DS.'local.xml', $files)) {
            $this->_isLocalConfigLoaded = true;
        }
        return $this;
    } 

如果您想了解有关local.xml的更多信息,请参阅此内容。

希望你现在能更清楚地理解。