Pagination 它是如何在prestashop中分页的?

Pagination 它是如何在prestashop中分页的?,pagination,prestashop,Pagination,Prestashop,我已经做了一些修改,现在需要构建自己的分页 我知道prestashop有他自己的那我怎么用呢 我试图在class/controller/FrontController.php中使用 使用功能: public function pagination($nbProducts = 10) {.... 但我不能很好地理解分页本身是如何形成的。。。我认为我的php知识不多,因此如果有人了解Prestashop的分页是如何工作的,我需要一些帮助。Front Controller为您想要查看

我已经做了一些修改,现在需要构建自己的分页

我知道prestashop有他自己的那我怎么用呢

我试图在class/controller/FrontController.php中使用

使用功能:

public function pagination($nbProducts = 10)
        {....

但我不能很好地理解分页本身是如何形成的。。。我认为我的php知识不多,因此如果有人了解Prestashop的分页是如何工作的,我需要一些帮助。

Front Controller为您想要查看的页面分配产品和smarty variables中的产品数。 下面是BestSalesController中的BestSales页面示例:

$nbProducts = (int)ProductSale::getNbSales();
$bestSales = ProductSale::getBestSales($this->context->language->id, $this->p - 1, $this->n, $this->orderBy, $this->orderWay);
....
// then assign it to smarty
$this->context->smarty->assign(array(
     'nbProducts' => $nbProducts,
     'products' => $bestSales
));
在前端控制器中没有什么特殊或定制的事情可以做

如果要进行自定义分页,请查看块分层模块

例如,在modules/blocklayered/blocklayered.php的
ajaxCall()
函数中,您可以通过编辑以下行为“按页面列出的产品数量”指定自定义选项:

$nArray = (int)Configuration::get('PS_PRODUCTS_PER_PAGE') != 10 ? array((int)Configuration::get('PS_PRODUCTS_PER_PAGE'), 10, 20, 50) : array(10, 20, 50);
此行显示在Back Office/Preferences/products中指定的每页产品的10、20、50和默认数量,但您可以根据自己的意愿进行更改,例如:

$nArray = array(10, 20, 30, 40, 50, 60);

如果您想进行自定义,必须在此模块中进行,但这并不简单(文件达到4200行,祝您好运!)。

分页是在themes/your_theme_name/pagination.tpl中形成的。在这里,您可以看到该分页的html和smarty代码。我不理解,但我需要理解它在Controller中的工作方式,我的意思是如何(如果可能的话)对我自己的产品列表使用我自己的分页。谢谢,我还不够清楚,但我需要在Prestashop中基于existing创建我自己的分页,但现在我明白了,如果不在override中编写自己的代码是不可能的。