gpt4 book ai didi

php - 在 Prestashop ModuleAdminController 中添加自定义行操作

转载 作者:可可西里 更新时间:2023-10-31 22:55:24 26 4
gpt4 key购买 nike

我想为 moduleadmincontroller helper 中的每一行添加一个下载按钮。

我尝试通过在 RenderList 函数上使用以下代码来添加它。但它不起作用。

$this->addRowAction('download');

如果我可以为每一行添加自定义操作以及如何处理它,请告诉我。

最佳答案

如您所知,操作是具有默认值的默认数组 array('view', 'edit', 'delete', 'duplicate');你可以使用它,但如果你想添加新的 Action ,你应该使用一些功能。例如你可以去 your_prestashop/controllers/admin/AdminRequestSqlController.php此类添加名称为“导出”的新操作

          $this->addRowAction('export');

然后使用 displayExportLink() 函数为此操作创建链接,如您在下面的代码中所见

         public function displayExportLink($token, $id)
{
$tpl = $this->createTemplate('list_action_export.tpl');

$tpl->assign(array(
'href' => self::$currentIndex.'&token='.$this->token.'&
'.$this->identifier.'='.$id.'&export'.$this->table.'=1',
'action' => $this->l('Export')
));

return $tpl->fetch();
}

然后您可以使用 initProcess() 函数或 initcontent() 函数获取您的新操作并执行类似下载的操作

public function initProcess()
{
parent::initProcess();
if (Tools::getValue('export'.$this->table))
{
$this->display = 'export';
$this->action = 'export';
}
}

关于php - 在 Prestashop ModuleAdminController 中添加自定义行操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20596175/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com