You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Edit: This fix break the hasPrev() functions. This can be solved somehow for sure, just noting it here, so you do not forget to change that as well!
Issue B
Now that we have fixed the length, we would expect the pagination menu to disappear, if the limit is not reached. But that does not happen, because now pagination|length will return 4. Why does it happen? Thatswhy:
pagination is set to true, which is string of length 4.
Fix
We can fix that, by checking the type inside the twig template:
{% if (pagination|gettype == 'object') and pagination|length > 1 %}
However I am not sure, if that is the best way to do. We could also use an empty element, but that caused the whole template to not render at all. But this is an issue you should be able to fix, as I am new to all the code, and you could think of a better solution and you know if they string true is required or not.
Hope that explanation is detailed enough. :-)
The text was updated successfully, but these errors were encountered:
I found multiple issues with the current pagination plugin. I have some solutions, but you must decide which one will fit best.
My goals:
Currently the twig template checks, if the pagination length is greater than 1:
grav-plugin-pagination/templates/partials/pagination.html.twig
Line 4 in 240fd7b
Issue A
The Item index is wrong (one too high). If you have 10 Items, limit set to 5, you'd expect to have 2 paginations. The length will output 3!
grav-plugin-pagination/classes/plugin/PaginationHelper.php
Lines 61 to 68 in 240fd7b
Fix
We need to place the items to
x-1
, because the counting starts at1
, not0
.Edit: This fix break the hasPrev() functions. This can be solved somehow for sure, just noting it here, so you do not forget to change that as well!
Issue B
Now that we have fixed the length, we would expect the pagination menu to disappear, if the limit is not reached. But that does not happen, because now
pagination|length
will return4
. Why does it happen? Thatswhy:grav-plugin-pagination/pagination.php
Lines 140 to 148 in 240fd7b
pagination
is set totrue
, which isstring
of length4
.Fix
We can fix that, by checking the type inside the twig template:
{% if (pagination|gettype == 'object') and pagination|length > 1 %}
However I am not sure, if that is the best way to do. We could also use an empty element, but that caused the whole template to not render at all. But this is an issue you should be able to fix, as I am new to all the code, and you could think of a better solution and you know if they string
true
is required or not.Hope that explanation is detailed enough. :-)
The text was updated successfully, but these errors were encountered: