我正在尝试创建我的模块来扩展 magento 1.9.1 中的一个功能。
我不知道我做错了什么,我使用了链接,除了名字之外,一切看起来都一样。
还有一个问题,如何将参数添加到 url 并路由以将它们传递给函数?
我尝试了下面的网址:
http://www.example.com/Kingdom_PatterModule
http://www.example.com/patter_sendrequest/
http://www.example.com/index.php/patter_sendrequest
http://www.example.com/index.php/patter_sendrequest/index
我的模块路径是:
local/
Kingdom/
/PatterModule
/controllers
IndexController.php
/etc
config.xml
在我的代码下面:
我的app/etc/modules/Kingdom_PatterModule.xml
<?xml version="1.0"?>
<config>
<modules>
<Kingdom_PatterModule>
<active>true</active>
<codePool>local</codePool>
</Kingdom_PatterModule>
</modules>
</config>
我的app/code/local/Kingdom/PatterModule/etc/config.xml
<?xml version="1.0"?>
<config>
<modules>
<Kingdom_PatterModule>
<version>0.1.3</version>
</Kingdom_PatterModule>
</modules>
<frontend>
<routers>
<patter_sendrequest>
<use>standard</use>
<args>
<module>Kingdom_PatterModule</module>
<frontName>pattermodule</frontName>
</args>
</patter_sendrequest>
</routers>
</frontend>
</config>
我的控制器app/code/local/Kingdom/PatterModule/controllers/IndexController.php
<?php
class Kingdom_PatterModule_IndexController extends Mage_Core_Controller_Front_Action
{
public function indexAction()
{
echo 'Hello I'm working...';
}
}
?>
您似乎没有在前端添加布局部分,以便它在前端返回 404 页面
<routers>
<patter_sendrequest>
<use>standard</use>
<args>
<module>Kingdom_PatterModule</module>
<frontName>pattermodule</frontName>
</args>
</patter_sendrequest>
</routers>
<layout>
<updates>
<patter_sendrequest>
<file>pattermodule.xml</file>
</patter_sendrequest>
</updates>
</layout>
</frontend>
在 config.xml 中添加此代码后,在 pattermodule.xml 文件中写入索引操作。如果您需要更多说明,请告诉我们。