PrestaShop 1.6 后台分页无法正常工作
PrestaShop 1.6 Back Office pagination not working correctly
您好,我正在开发 PrestaShop paymnet 模块。我希望列出所有交易并使用 Helper List class 进行处理,我设置了分页选项,但分页无法正常工作。底部显示分页,如 1..2..4 页,但列出所有交易。这是渲染助手列表方法的部分代码。
$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);
感谢大家的帮助!如果我提出重复的问题,我很抱歉,但我的研究以失败告终。干杯!
我找到了解决这个问题的方法。只需添加对结果进行分页的功能。如果有人有类似的问题。下面我粘贴工作代码。
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;
}
您好,我正在开发 PrestaShop paymnet 模块。我希望列出所有交易并使用 Helper List class 进行处理,我设置了分页选项,但分页无法正常工作。底部显示分页,如 1..2..4 页,但列出所有交易。这是渲染助手列表方法的部分代码。
$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);
感谢大家的帮助!如果我提出重复的问题,我很抱歉,但我的研究以失败告终。干杯!
我找到了解决这个问题的方法。只需添加对结果进行分页的功能。如果有人有类似的问题。下面我粘贴工作代码。
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;
}