如何在 prestashop 中生成到模块控制器的链接? [英] how to generate a link to a module controller in prestashop?
问题描述
在 prestashop 中生成模块控制器链接的确切方法是什么?另外,应该如何真正命名控制器的类以及应该如何反映 url 参数?
What's the exact way to generate a link to a module controller in prestashop? Also, how should really be named the controller's class and how the url params should mirror?
推荐答案
您将使用 Link 类的实例.通常你不必创建一个,只需使用 context->link
(例如形成一个控制器 $this->context-link
).方法是getModuleLink()
,所以:
You will use an instance of the Link class. Generally you don't have to create one, just use context->link
(ex. form a controller $this->context-link
). The method is getModuleLink()
, so:
$this->context->link->getModuleLink('module_folder_name','controller_name',array_of_params);
注意命名:
模块文件夹名称正是..
Module folder name is exactly that..
控制器必须在正确的路径中,例如module/controllers/front/controller.php
The controller must be in the right path, so for example module/controllers/front/controller.php
文件名是动作,小写.类名是 ModuleFolder+Action+"ModuleFrontController"
The file name is the action, lowercase. The class name is ModuleFolder+Action+"ModuleFrontController"
例如:
模块目录:订单附件
控制器: orderattachment/controllers/front/pdf.php
controller: orderattachment/controllers/front/pdf.php
控制器类:
class OrderAttachmentPdfModuleFrontController extends ModuleFrontController
链接:
$this->context->link->getModuleLink('orderattachments', 'pdf', [params..]);
这篇关于如何在 prestashop 中生成到模块控制器的链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!