添加行操作 Prestashop
addRowAction Prestashop
我正在 Prestashop 上创建一个模块,我想使用 addRowAction() 创建一个按钮,当我单击此按钮时,我想打开一个包含产品详细信息的页面。这是一个例子:
我找到了 this 篇文章,但我希望我的模块在不更改核心文件的情况下自动执行此操作
1) 添加附加操作:
$this->addRowAction('test');
2)这个动作函数:
public function displayTestLink($token = null, $id, $name = null)
{
$tpl = $this->createTemplate('helpers/list/list_action_edit.tpl');
if (!array_key_exists('Test', self::$cache_lang))
self::$cache_lang['Test'] = $this->l('Test', 'Helper');
$tpl->assign(array(
'href' => $this->currentIndex.'&'.$this->identifier.'='.$id.'&update'.$this->table.'&token='.($token != null ? $token : $this->token),
'action' => self::$cache_lang['Test'],
'id' => $id
));
return $tpl->fetch();
}
3) 在函数中你可以渲染一个新的表单,做一些你喜欢的事情。
首先我必须加上public function __construct()
$this->addRowAction('buttonname');
public function displayButtonnameLink($token = null, $id)
{
$tpl = $this->createTemplate('helpers/list/list_action_buttonname.tpl');
$href = 'linkhere';
$tpl->assign(array(
'id' => $id,
'href' => $href,
'action' => $this->l('Button Name')
));
return $tpl->fetch();
}
并在
/prestashop/modules/module_name/views/templates/admin/module_name/helpers/list/list_action_buttonname.tpl
<a id="a{$id|escape:'html':'UTF-8'}" href="{$href|escape:'html':'UTF-8'}" title="{$action|escape:'html':'UTF-8'}" class="edit">
<i class="icon-truck"></i>
{$action|escape:'html':'UTF-8'}
</a>
与@manl 的答案相同,但有更多细节。
谢谢@manl.
我正在 Prestashop 上创建一个模块,我想使用 addRowAction() 创建一个按钮,当我单击此按钮时,我想打开一个包含产品详细信息的页面。这是一个例子:
我找到了 this 篇文章,但我希望我的模块在不更改核心文件的情况下自动执行此操作
1) 添加附加操作:
$this->addRowAction('test');
2)这个动作函数:
public function displayTestLink($token = null, $id, $name = null)
{
$tpl = $this->createTemplate('helpers/list/list_action_edit.tpl');
if (!array_key_exists('Test', self::$cache_lang))
self::$cache_lang['Test'] = $this->l('Test', 'Helper');
$tpl->assign(array(
'href' => $this->currentIndex.'&'.$this->identifier.'='.$id.'&update'.$this->table.'&token='.($token != null ? $token : $this->token),
'action' => self::$cache_lang['Test'],
'id' => $id
));
return $tpl->fetch();
}
3) 在函数中你可以渲染一个新的表单,做一些你喜欢的事情。
首先我必须加上public function __construct()
$this->addRowAction('buttonname');
public function displayButtonnameLink($token = null, $id)
{
$tpl = $this->createTemplate('helpers/list/list_action_buttonname.tpl');
$href = 'linkhere';
$tpl->assign(array(
'id' => $id,
'href' => $href,
'action' => $this->l('Button Name')
));
return $tpl->fetch();
}
并在
/prestashop/modules/module_name/views/templates/admin/module_name/helpers/list/list_action_buttonname.tpl
<a id="a{$id|escape:'html':'UTF-8'}" href="{$href|escape:'html':'UTF-8'}" title="{$action|escape:'html':'UTF-8'}" class="edit">
<i class="icon-truck"></i>
{$action|escape:'html':'UTF-8'}
</a>
与@manl 的答案相同,但有更多细节。
谢谢@manl.