grav-plugin-pagination icon indicating copy to clipboard operation
grav-plugin-pagination copied to clipboard

Make page_count and current accessible from Twig

Open kylxbn opened this issue 3 years ago • 3 comments

There are times when it is necessary to show the page_count and current page in Twig templates (for example, "2/6" to mean "page 2 of 6"). This pull request aims to expose variables current, items_per_page, and page_count.

I am not good with making pull requests, so if there is any mistake, please tell me, and I will try my best to fix it. Thanks!

kylxbn avatar Mar 01 '22 06:03 kylxbn

@mahagr , thank you very much for your feedback. I apologize for not adding docblocks in advance, because I wasn't sure which type the variables were in. However, after making sure that all are integers (after casting one double to int because ceil() returns a double), I added proper @return annotations.

I hope this is okay now. If there are any other mistakes, please tell me!

kylxbn avatar Mar 02 '22 05:03 kylxbn

Looks good to me!

mahagr avatar Mar 02 '22 07:03 mahagr

@mahagr , thank you very much for your patience. I originally intended to use casts but I was unsure, and the internet misguided me. I apologize.

kylxbn avatar Mar 02 '22 09:03 kylxbn