php – 覆盖Magento Contacts Controller

发布时间:2022-04-30 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了php – 覆盖Magento Contacts Controller脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
我试图覆盖Mage / Contacts / IndexController.PHP @H_304_1@我在本地创建了一个文件夹,并创建了Mynamespace / CustomContacts / controllers / IndexController.PHP

<?PHP

require_once 'Mage/Contacts/controllers/IndexController.PHP';

class Mynamespace_CustomContacts_IndexController extends Mage_Contacts_IndexController {

    PRotected function indexAction () {
        die;
    }
}

我还将此代码放在Mynamespace / CustomContacts / etc / config.XMl中

<config>
    <frontend>
        <routers>
            <contacts>
                <args>
                     <;modules>
                        <Mynamespace_CustomContacts before="Mage_Contacts">Mynamespace_CustomContacts</Mynamespace_CustomContacts>
                    </modules>
                </args>
            </contacts>
        </routers>
    </frontend>
</config>

我清理了缓存,但我死了;不起作用,

谢谢你的帮助

1.最佳实践

您的config.xML文件如下所示:

<?xml version="1.0"?>
<config>
    <modules>
        <Mynamespace_CustomContacts>
            <version>0.1.0</version>
        </Mynamespace_CustomContacts>
    </modules>
    <frontend>
        <routers>
            <contacts>
                <args>
                    <modules>
                        <Mynamespace_CustomContacts before="Mage_Contacts">Mynamespace_CustomContacts</Mynamespace_CustomContacts>
                    </modules>
                </args>
            </contacts>
        </routers>
    </frontend>
</config>

2.糟糕的做法

您可以在app / local / Mage / Contacts / controllers / IndexController.PHP中移动控制器以进行硬覆盖.

并且不要忘记在app / etc / modules目录中的xml文件中启用您的模块

脚本宝典总结

以上是脚本宝典为你收集整理的php – 覆盖Magento Contacts Controller全部内容,希望文章能够帮你解决php – 覆盖Magento Contacts Controller所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。