这就是我今天所做的:
我的后台控制器:工作精细
class AdminAvantokeyLogController extends ModuleAdminController
{
public function __construct()
{
$this->bootstrap = true;
$this->table = 'avanto_log';
$this->className = "AvantoLog";
$this->_defaultOrderBy = 'id_avanto_log';
$this->addRowAction('edit');
$this->addRowAction('delete');
$this->addRowAction('mail'); //this is my custom button
$this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'),
'confirm' => $this->l('Delete selected items?')), );
$this->fields_list = array(
'id_avanto_log' => array(
'title' => $this->l('Key ID'),
'width' => 20,
),
'serial_key' => array(
'title' => $this->l('Serial Keys'),
'width' => 200,
),
'product_name' => array(
'title' => $this->l('Product Name'),
'width' => 50,
),
);
parent::__construct();
}
这是同一控制器中的displayMaillink方法:工作精细
public function displayMailLink($token, $id)
{
$this->context->smarty->assign(
array(
'href' => self::$currentIndex.'&token='.$this->token.'&'.$this->identifier.'='.$id.'&mail'.$this->table.'=1',
'action' => $this->l('Mail')
)
);
$content = $this->context->smarty->fetch(_PS_MODULE_DIR_ . "avanto_key/views/templates/admin/list_action_test.tpl");
return $content;
}
单击“邮件”按钮时,不会触发此processMail()方法:
public function processMail()
{
mail("info@customit.be" , "test message from export" , "this is my message content");
}
有人能指出我正确的方向吗?我已经从Admincontroller和buildcontroller中的build中复制了方法。但我没有被触发。谢谢你们!
答案 0 :(得分:0)
对于默认操作添加,编辑,删除,查看,导出等,AdminController类将检测并解析来自GET参数的操作,但是对于自定义操作,您需要自己在控制器中定义操作属性,以便{ {1}}被调用。
EventState.STATE_PROCESSED
既然已经定义了自定义操作,AdminController可以call您的流程操作方法。