覆盖Magento联系人控制器 [英] Override Magento Contacts Controller
本文介绍了覆盖Magento联系人控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试覆盖Mage/Contacts/IndexController.php
我在本地创建了一个文件夹,并创建了Mynamespace/CustomContacts/controllers/IndexController.php
I created a folder in local and created 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>
我清理了缓存,但死了;不起作用,
I cleaned the cache, but my die; does not work,
感谢您的帮助
推荐答案
1.最佳做法
您的config.xml
文件看起来像这样:
1. Best practices
Your config.xml
file seems like this:
<?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
中进行硬覆盖.
2. Bad practices
You can move your controller in app/local/Mage/Contacts/controllers/IndexController.php
for a hard override.
不要忘记在app/etc/modules目录的xml文件中启用模块
这篇关于覆盖Magento联系人控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文