【问题标题】:Magento 1.9 module returns 404Magento 1.9 模块返回 404
【发布时间】:2015-06-17 20:35:25
【问题描述】:

我正在尝试创建我的模块以扩展 magento 1.9.1 中的一项功能。
我不知道我做错了什么,我使用了Link,除了名称之外,一切看起来都一样。

还有一个问题,如何将参数添加到 url 和 route 以将它们传递给 function ?

我尝试了以下网址:

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...';
    }

}
?>

【问题讨论】:

标签: php magento


【解决方案1】:

您似乎没有在前端添加布局部分,因此它在前端返回 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 文件中写入索引操作。如果您需要更多说明,请告诉我们。

【讨论】:

  • 控制器工作不需要布局。如果您的控制器仅是 API 或仅顺便请求 Ajax,您会在此布局中放置什么?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2020-11-26
  • 1970-01-01
  • 2016-03-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-10-08
相关资源
最近更新 更多