Problem/Motivation
If you use the [view:page-count] in a view that have no content, it returns 0 even if the [view:current-page] token returns 1.
So if you want to show something like "page [view:current-page] on [view:page-count]" you'll get "page 1 on 0" what is confusing.
Beta phase evaluation
| Issue category | Bug because it is not the expected behaviour |
|---|---|
| Issue priority | Minor |
| Unfrozen changes | Unfrozen because it only changes strings. |
| Prioritized changes | The main goal of this issue is usability. |
| Disruption | Not disruptive as if people wanted to deal with it they'd have altered the token replacement in a way that won't break with this change. |
Proposed resolution
Return 1 instead of 0 if there is no content to show in the View.
Remaining tasks
Patch, Review, Commit
User interface changes
The views that use the [view:page-count] token will show 1 instead of 0.
API changes
None.
Data model changes
None.
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | view-page-count-2510076-1.patch | 2.55 KB | duaelfr |
| #1 | view-page-count-2510076-1-tests-only.patch | 1.9 KB | duaelfr |
Comments
Comment #1
duaelfrImproved tests to show the issue.
Comment #3
lnadella commentedThis patch is applied, reviewed and working as expected. After applying the patch, tokens given in Header of the view "page [view:current-page] on [view:page-count]" gives "page 1 on 1".
Comment #4
catchCommitted/pushed to 8.0.x and cherry-picked to 8.0.x. Thanks!
Comment #7
mikeker commented$view->result contains the rows being displayed on the current page. (In D7, I believe, it held the entire result set). So
page-countwill always be one.See #2572355: Some view tokens ([view:page-count] and [view:total-rows]) are incorrect, which was just rerolled to apply cleanly with the fix in this issue. So, if this issue is reverted, then 2572355 will need another reroll, or 2572355-31 can be applied on top of this fix. Not sure which is cleaner...
Comment #8
duaelfrI don't think we should revert this commit as it only introduces a
max()call that does not change the original behavior.If there is a problem with the token itself, it should be fixed in the other issue.
Let's keep this issue closed and move to the other one that already have a patch.