您好我正在开发PrestaShop paymnet模块。我希望列出所有事务并使用Helper List类进行,我设置了paggination选项,但是paggination无法正常工作。在底部显示像1..2..4页面的paggionation,但列出所有交易。这是来自渲染助手列表方法的代码的一部分。
$helper = new HelperList();
$helper->show_toolbar = false;
$helper->no_link = true;
$helper->_pagination = array(10, 20, 50, 100, 200);
$content = $this->getCancelRows();
$helper->listTotal = count($this->getCancelRows());
return $helper->generateList($content, $this->fields_list);
感谢所有帮助!如果我问一个相关的问题,我很抱歉,但我的研究结果却没有成功。干杯!
答案 0 :(得分:1)
我找到了解决这个问题的方法。只需添加功能即可对结果进行分页。如果有人有类似的问题。下面我粘贴工作代码。
public function initList() {
$content = $this->getCancelRows();
$helper->listTotal = count($this->getCancelRows());
/* Paginate the result */
$page = ($page = Tools::getValue('submitFilter' . $helper->table)) $page : 1;
$pagination = ($pagination = Tools::getValue($helper->table . '_pagination')) ? $pagination : 10;
$content = $this->paginate_content($content, $page, $pagination);
return $helper->generateList($content, $this->fields_list);
}
public function paginate_content($content, $page = 1, $pagination = 10){
if (count($content) > $pagination) {
$content = array_slice($content, $pagination * ($page - 1), $pagination);
}
return $content;
}