dr6673999 2011-07-13 19:52
浏览 52
已采纳

Magento模块IndexController - IndexAction函数404的

Removing the Class around the IndexAction causes a server error, so I know the code is running as expected up to that point.

class Foo_Bar_IndexController extends Mage_Core_Controller_Front_Action{
    public function indexAction(){
        echo "<h1>Echo from indexcontroller.</h1>";
    }
}

Ideally the echo would be replaced by loading template files, but I've been stuck on it 404ing for the last 2 days and just want to get past that.

I've read through about a dozen tutorial, followed 4 to completetion, but this issue pops up every time. Does anyone have an idea what could be causing this?

Edit-- Sorry, for the brevity. I wasn't sure how much I should distend the page.

@ Alan Storm -- I found your tutorial here. http://alanstorm.com/magento_controller_hello_world (Great Detail, very helpful in understanding what all the xml tags do). This is a copy of that tutorial with Foo replacing Alanstormdotcom and Bar replacing Helloworld. Even copy/pasting I end up with the same 404.

Here is my current config file: PATH: app/code/local/Foo/Bar/etc/config.xml (edit: corrected path)

<config>
<modules>
    <Foo_Bar>
        <version>0.1.0</version>
    </Foo_Bar>
</modules>
<frontend>
    <routers>
        <bar>
            <use>standard</use>
            <args>
                <module>Foo_Bar</module>
                <frontName>bar</frontName>
            </args>
        </bar>
    </routers>  
</frontend>
</config>

Edit--- the last remaining file Path: app/etc/modules/Foo_Bar.xml

<config>
<modules>
    <Foo_Bar>
        <active>true</active>
        <codePool>local</codePool>
    </Foo_Bar>
</modules>
</config>       
  • 写回答

3条回答 默认 最新

  • dqba94619 2011-07-14 14:37
    关注

    Your path is incorrect:

    app/etc/modules/Foo/Bar/etc/config.xml
    

    You should place your module's definition file Foo_Bar.xml in app/etc/modules and the code of your module in app/code/local:

    app/code/local/Foo/Bar/etc/config.xml
    app/code/local/Foo/Bar/controllers/IndexController.php
    

    EDIT: in order to access your controller you should access this url:

    www.example.com/magento-instance/bar/index
    

    Following this pattern:

    {magento_root}/{magento_module}/{magento_controller}/{magento_action}

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 python按要求编写程序
  • ¥15 Python输入字符串转化为列表排序具体见图,严格按照输入
  • ¥20 XP系统在重新启动后进不去桌面,一直黑屏。
  • ¥15 opencv图像处理,需要四个处理结果图
  • ¥15 无线移动边缘计算系统中的系统模型
  • ¥15 深度学习中的画图问题
  • ¥15 java报错:使用mybatis plus查询一个只返回一条数据的sql,却报错返回了1000多条
  • ¥15 Python报错怎么解决
  • ¥15 simulink如何调用DLL文件
  • ¥15 关于用pyqt6的项目开发该怎么把前段后端和业务层分离