【问题标题】:how to use other function in the same controller in magento?如何在magento的同一控制器中使用其他功能?
【发布时间】:2016-03-02 10:27:33
【问题描述】:

我正在尝试在本地创建新模块。现在模块正在检测名称为IndexController.php。该控制器由 indexAction 和 testAction 两个功能组成。 现在 testAction 未检测到,但 indexAction 已检测到。 我正在使用此链接运行控制器localhost/magentoproject/index.php/test/index,它按预期运行 但是当我尝试运行 localhost/magentoproject/index.php/test/test 时显示 404 未找到。

这是结构 indexController.php

class Pfay_Test_IndexController extends Mage_Core_Controller_Front_Action {

public function IndexAction() {

    $this->loadLayout();
    $this->renderLayout();
    //echo 'test index';
}
public function testAction() {
    echo 'test mymethod';
}
}

this is when im run localhost/magentoproject/index.php/test/index

this is when im run localhost/magentoproject/index.php/test/test

【问题讨论】:

  • echo 'test mymethod';之后尝试die()

标签: php magento controller


【解决方案1】:

路径为moduelname/controllername/actionmethod,在您的情况下,模块名称为test,控制器名称为index,操作方法为test

所以网址将是localhost/magentoproject/index.php/test/index/test

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-06-07
    • 1970-01-01
    • 1970-01-01
    • 2013-07-04
    • 2017-12-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多