YuriiChmil
YuriiChmil

Reputation: 481

Show how many pages in Knp pagination

I install and override template in knp pagination. But I need show how many pages are. For example: 1 page of 10, 5 page of 10 e.t.c?I read offical documentation but I dosen't find ansver.

Upvotes: 1

Views: 5895

Answers (2)

BENARD Patrick
BENARD Patrick

Reputation: 30975

I can see at the doc this abstract pagination class : https://github.com/KnpLabs/knp-components/blob/master/src/Knp/Component/Pager/Pagination/AbstractPagination.php

This class has a method on line 113:

/**
 * Get total item number available
 *
 * @return integer
 */
public function getTotalItemCount()
{
    return $this->totalCount;
}

Upvotes: 1

Ulti
Ulti

Reputation: 608

You can override this template : https://github.com/KnpLabs/KnpPaginatorBundle/blob/master/Resources/views/Pagination/sliding.html.twig

Just use the variable pageCount to display the amount of pages where you want.

To do so, create a sliding.html.twig file in your app/Resources/KnpPaginatorBundle/views/Pagination folder.

Upvotes: 8

Related Questions