覆盖magento';的问题;核心联系我们的形式


Issues with overriding magento's core contact us form

我已经成功地覆盖了magento的默认联系我们表单,并添加了额外的字段和功能,它似乎可以工作。

问题是,当我在magento中禁用我的模块时,我定制的联系我们表格会显示出来,而不是默认的。

我的假设是,只有当我的模块处于活动状态时,我的定制(操作方法和模板)才会可用/显示。

我认为我的问题是覆盖布局,块,模板。

一些建议会很好。

这是我的代码:

app/code/local/MyCompany/ContactsExtension/etc/config.xml

<config>
   <modules>
        <MyCompany_ContactsExtension>
            <version>0.1.0</version>  
        </MyCompany_ContactsExtension>
   </modules>
<frontend>
    <routers>
        <contacts>
            <args> 
                <modules> 
                    <MyCompany_ContactsExtension before="Mage_Contacts">MyCompany_ContactsExtension</MyCompany_ContactsExtension> 
                </modules> 
            </args> 
        </contacts>
    </routers>
</frontend>
<global>
    <blocks>
        <contactsextension>
            <class>MyCompany_ContactsExtension_Block</class>
        </contactsextension>
    </blocks>
   <helpers>
        <contactsextension>
            <class>MyCompany_ContactsExtension_Helper</class>
        </contactsextension>
    </helpers>           
</global>
</config>

基本上,我复制了默认的contacts.xml并添加了我的更改。我想我可能没有正确地更新它。

app/design/frontend/enterprise/metheme/layout/contactsextension.xml

<layout version="0.1.0">
    <default>
        <reference name="footer_links">
            <action method="addLink" translate="label title" module="contacts" ifconfig="contacts/contacts/enabled"><label>Contact Us</label><url>contacts</url><title>Contact Us</title><prepare>true</prepare></action>
        </reference>
    </default>
<contacts_index_index translate="label">
    <label>Contact Us Form</label>
    <reference name="head">
        <action method="setTitle" translate="title" module="contacts"><title>Contact Us</title></action>
    </reference>
    <reference name="root">
        <action method="setTemplate"><template>page/2columns-right.phtml</template></action>
        <action method="setHeaderTitle" translate="title" module="contacts"><title>Contact Us</title></action>
    </reference>
    <reference name="content">
        <block type="core/template" name="contactForm" template="contactsextension/form.phtml">
            <block type="contactsextension/additionalfield" name="contacts.addfields" as="addfields" template="contactsextension/additionalfield.phtml" />
        </block>    
    </reference>
</contacts_index_index>
</layout>

谢谢,杜尼亚。

是的,您需要在<frontend>部分的模块配置中定义布局更新,如下所示:

<layout>
    <updates>
        <uniquehandle>
            <file>module_layout.xml</file>
        </uniquehandle>
    </updates>
</layout>

然后,当您禁用模块时,它应该可以正常工作。否则,Magento加载在主题的布局文件夹中找到的所有布局更新

有两种方法可以"禁用"扩展,我将单词disable放在引号中,因为其中一种方法只禁用输出。根据您当前禁用的方式,请确保也尝试其他方法。

  1. 在管理区域中,转到系统>配置>高级>高级>禁用模块输出,然后为您的扩展选择禁用。然而,正如它所说,这只会禁用输出。如果您的扩展执行一些其他任务,如观察事件,这种情况仍将继续
  2. 要完全禁用扩展,请转到app/etc/modules/company_module.xml,将标签中的true改为false:

    <config>
        <modules> 
            <company_module> 
                <active>true</active> 
                <codePool>local</codePool> 
            </company_module> 
    </modules>