如何在 Prestashop 1.7 中分页?

问题描述

我想在 Prestashop 1.7 中创建分页

我有一个带数组的函数,我将其分配给 .tpl 模板

$brands = $this->getBrands();
$this->context->smarty->assign($brands);
parent::initContent();
$this->setTemplate('brandschr.tpl');

我没有找到太多关于如何使用 pagination.tpl 的信息或如何使用的示例。

如果你以前做过或者任何例子,请把你的想法发给我。

解决方法

我建议您仅将 smarty 可变地分配给需要它的页面。因此,假设您想将品牌添加到您的自定义分页中,您只需在实际包含品牌的页面上指定它。

$brands = $this->getBrands();
$this->context->smarty->assign($customPagination);

然后在 /templates/_partials/pagination.tpl 的主题中创建一个覆盖。 在此文件中,只需检查您的“customPagination”是否已设置,然后显示您的 custom-pagination.tpl (brandschr.tpl)

这将保持原始 PS 分页不变。