Search code examples
phppaginationprestashopsmartyprestashop-1.7

how to pagination in Prestashop 1.7?


I would like to create a pagination in PrestaShop 1.7

I have a function with an array, which I assign to a .tpl template

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

I have not found much information how to use pagination.tpl or an example how to do it.

Please send me your idea if you have done it before or any example for me.


Solution

  • I would advise you to assign smarty variably only to the pages where it is needed. So let's say you want to add brands to your custom pagination, you only assign this on the pages that actually contain a brand.

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

    And then create an override in the theme at /templates/_partials/pagination.tpl. In this file, just check if your "customPagination" isset and then display your custom-pagination.tpl (brandschr.tpl)

    This will keep the original PS pagination intact.