首页 > 解决方案 > 如何在 Prestashop 1.7 中进行分页?

问题描述

我想在 Prestashop 1.7 中创建一个分页

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

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

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

如果您以前做过或为我提供任何示例,请将您的想法发送给我。

标签: phppaginationprestashopsmartyprestashop-1.7

解决方案


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

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

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

这将保持原始 PS 分页完好无损。


推荐阅读