0

我有一个包含以下内容的 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 块?

4

1 回答 1

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的更多信息,请参阅此内容。

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

于 2013-09-04T04:22:17.160 回答