作者热门文章
- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我想为 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/
我想为 moduleadmincontroller helper 中的每一行添加一个下载按钮。 我尝试通过在 RenderList 函数上使用以下代码来添加它。但它不起作用。 $this->addRo
我是一名优秀的程序员,十分优秀!