与压倒一切的Magento的核心问题与我们联系形成
我已成功地重写Magento的默认与我们联系形式,附加字段和功能,它似乎工作。与压倒一切的Magento的核心问题与我们联系形成
的问题是,当我禁用我的模块在Magento,我的定制与我们联系形式显示,而不是默认。
我的假设是,只有当我的模块是活动的,那么我的定制(操作方法和模板)将可用/显示。
我觉得我的问题是与压倒一切的布局,块,模板做。
有些建议会很好。
这里是我的代码:
应用程序/代码/本地/ 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并添加我的变化。我想我可能没有正确更新它。
应用程序/设计/前端/企业/ mytheme的/布局/ 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>
感谢, duniya。
是的,你需要定义你的模块配置在<frontend>
节,你有这样的布局更新:
<layout>
<updates>
<uniquehandle>
<file>module_layout.xml</file>
</uniquehandle>
</updates>
</layout>
然后守当你禁用你的模块时,ld可以正常工作。否则,Magento的载荷主题
有两种方法为“禁用”的延伸,我把这个词加上引号,因为禁用仅一个禁止输出。根据您目前禁用的方式,请确保您也尝试其他方法。
- 在管理员区域,进入系统>配置>高级>高级>禁用模块输出,并为您的扩展选择禁用。正如它所说,但是,这只会禁用输出。如果您的扩展程序执行其他任务(如观察事件),则此操作仍将继续。
-
要完全禁用扩展到应用程序的/ etc /模块/ company_module.xml真更改为false在标签:
<config> <modules> <company_module> <active>true</active> <codePool>local</codePool> </company_module> </modules>
非常感谢您的回复的布局文件夹中找到所有的布局更新。但是,我知道如何禁用magento中的模块。但是,我的问题是重写核心模块。即当我禁用我的模块时,magento仍在使用我的修改模板来联系我们而不是默认模板。如果有人可以检查我的配置文件,这将是有益的。我应该如何覆盖核心模块布局xml和模板。我是否需要复制contacts.xml布局并将其放入我的主题中?我是否需要在模块配置中添加一些内容以启用布局文件?欢呼 – user1136431 2012-01-08 10:15:43
谢谢,有道理。我以前试过这个,因为我发现了另一个关于layout.xml的*帖子,我按照你的说法添加了布局更新。但是,现在,当我在浏览器中加载联系我们页面时,表单在页面上显示两次。 2。如果我在app/etc/modules/company_module.xml中禁用了该模块,那么它将显示默认表单。但是,如果我在管理中禁用了该模块,它将使用我的修改后的表单。有任何想法吗?另外,什么是重写布局xml的最佳方式。我应该将contacts.xml复制到我的主题中,并进行一些更改。我需要在复制的文件中使用哪些特殊标签?干杯。 – user1136431 2012-01-08 23:50:31
我想你需要使用'“指令去除默认表单以避免重复。对于问题的第二部分:禁用模块输出不会禁用处理布局指令,因此您必须使用'ifconfig'指令为此案例添加额外的检查。这里有一些见解http://*.com/questions/5596193/magento-xml-layouts-specify-value-for-ifconfig –
Zifius
2012-01-09 16:54:52