Skip to content

Better control over Pagination stops#2302

Merged
jarednova merged 2 commits intotimber:masterfrom
IJMacD:patch-1
Aug 13, 2020
Merged

Better control over Pagination stops#2302
jarednova merged 2 commits intotimber:masterfrom
IJMacD:patch-1

Conversation

@IJMacD
Copy link
Copy Markdown
Contributor

@IJMacD IJMacD commented Aug 6, 2020

I had the case where I needed to hide the last pages of pagination (the very oldest posts).

I found the end_step (not documented anywhere) controlled how many pages are shown at either end of the pagination range.
Additionally I was not able to set this to zero to hide the pages completely.

My proposal is to allow zero pages to be shown at the ends of the list. Also to enable different values for the start and end. The start value defaults to the same as the end value for backwards compatibility.

Ticket: #

Issue

I needed to hide the last pages of pagination (the very oldest posts).

Solution

My solution is to add a new optional parameter to the paginate_links arg array allowing control over the start and end separately.
Also allow zero as a valid value for the ends of the list.

Impact

The new parameter defaults to the value of the old one so maintains perfect backwards compatibility.

Usage Changes

Considerations

Testing

I had the case where I needed to hide the last pages of pagination (the very oldest posts).

I found the `end_step` (not documented anywhere) controlled how many pages are shown at either end of the pagination range.
Additionally I was not able to set this to zero to hide the pages completely.

My proposal is to allow zero pages to be shown at the ends of the list. Also to enable different values for the start and end. The start value defaults to the same as the end value for backwards compatibility.
@coveralls
Copy link
Copy Markdown

coveralls commented Aug 6, 2020

Coverage Status

Coverage decreased (-2.4%) to 91.558% when pulling 99f0e98 on IJMacD:patch-1 into 5628c3b on timber:master.

@jarednova
Copy link
Copy Markdown
Member

@IJMacD thanks for the PR! Would you be up for writing some tests in TestTimberPagination to cover the new parameters you added?

The good news is that it seems that nothing about the prior behaviors are broken. While Travis is failing right now, it's due to an unrelated issue about changes in Twig (#2301)

@IJMacD
Copy link
Copy Markdown
Contributor Author

IJMacD commented Aug 8, 2020

I've added the tests and checked against the original code. I found that setting mid_size to 0 was previously permitted yet would cause a PHP Notice about an 'Undefined index: link' causing the test suite to fail so I fixed that too.

I was aware of #2301. If you need to see green ticks from the tests I can rebase if you'd like?

@jarednova
Copy link
Copy Markdown
Member

This is great, thanks @IJMacD ! Really appreciate all the permutations of tests/sizes so we can make sure things (keep) behaving into the future.

@jarednova jarednova merged commit 3dc9440 into timber:master Aug 13, 2020
@IJMacD IJMacD deleted the patch-1 branch August 14, 2020 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants