[英]Opencart call function from module controller
I've tried asking this on Opencart forums ( thread link ), but still can't quite get it, though someone tried to explain this to me. 我试过在Opencart论坛上讨论这个问题( 线程链接 ),但仍然无法得到它,尽管有人试图向我解释这一点。 I hope someone here can help.
我希望这里有人可以提供帮助。
I've written some extensions before where I have a custom function in the controller called from view , for example: if I edit admin/controller/sale/customer.php and after index() function add 之前我在控制器中调用自定义函数之前编写了一些扩展,例如:如果我编辑admin / controller / sale / customer.php并在index()函数之后添加
public function foo(){
//code here
}
I can access it by using 我可以通过使用来访问它
index.php?route=sale/customer/foo
Now I have a module in catalog, could I access a function in it's controller from view, in the below example "foo"? 现在我在目录中有一个模块,我可以从视图中访问它的控制器中的一个函数,在下面的示例“foo”中?
my_module.php: my_module.php:
class ControllerModuleMyModule extends Controller {
protected function index($setting) {
...
}
public function foo(){
...
}
Basically, I want to make an AJAX call to it from whatever page/route the module is on. 基本上,我想从模块所在的任何页面/路由中对它进行AJAX调用。 Many thanks in advance.
提前谢谢了。
This can be done in the same way you would for any module. 这可以按照与任何模块相同的方式完成。 For instance, if you'd added
foo()
to /catalog/controller/module/cart.php
you would use 例如,如果您将
foo()
添加到/catalog/controller/module/cart.php
那么您将使用
index.php?route=module/cart/foo
There's nothing special about the module controllers compared with any other accessible module 与任何其他可访问模块相比,模块控制器没有什么特别之处
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.