Override Magento Contacts Controller(覆盖 Magento 联系人控制器)
本文介绍了覆盖 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
文件看起来像这样:
<?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 联系人控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
沃梦达教程
本文标题为:覆盖 Magento 联系人控制器


猜你喜欢
- PHP - if 语句中的倒序 2021-01-01
- 如何从数据库中获取数据以在 laravel 中查看页面? 2022-01-01
- Oracle 即时客户端 DYLD_LIBRARY_PATH 错误 2022-01-01
- PHP foreach() 与数组中的数组? 2022-01-01
- 使用 GD 和 libjpeg 支持编译 PHP 2022-01-01
- 如何使用 Google API 在团队云端硬盘中创建文件夹? 2022-01-01
- Laravel 5:Model.php 中的 MassAssignmentException 2021-01-01
- 覆盖 Magento 社区模块控制器的问题 2022-01-01
- openssl_digest vs hash vs hash_hmac?盐与盐的区别HMAC? 2022-01-01
- 如何在 Symfony2 中正确使用 webSockets 2021-01-01