【问题标题】:PrestaShop 1.6 Back Office pagination not working correctlyPrestaShop 1.6 后台分页无法正常工作
【发布时间】:2017-07-05 06:25:20
【问题描述】:

您好,我正在开发 PrestaShop paymnet 模块。我希望列出所有事务并使用 Helper List 类进行,我设置了分页选项,但分页不能正常工作。底部显示类似于 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);

感谢大家的帮助!如果我提出重复的问题,我很抱歉,但我的研究以失败告终。干杯!

【问题讨论】:

    标签: php prestashop payment prestashop-1.6


    【解决方案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;
    
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-12-14
      • 2014-09-21
      • 2013-08-22
      • 2012-09-25
      • 2016-07-29
      • 2017-11-27
      • 1970-01-01
      相关资源
      最近更新 更多