Problem/Motivation
When using the "Alternating view mode"-option in the Display Suite row plugin, it is possible to trigger incorrect view modes on items.
Our scenario:
- Fixed number of elements on the homepage
- Element 1 has view mode V1, elements 2-3-4 have view mode V2
- No pager
Occassionally, we would see all 4 elements in view mode V1. Clearing the cache always resolved this issue. After debugging, we tracked this down to legacy URL's hitting the site. The previous iteration of the site did contain a pager on the homepage. Whenever a legacy URL containing "?page=1" hit the site, the current display suite logic (taking the page number straight from the URL) assumed that we were no longer on the first page (even though views was still showing the first 4 elements, and there is no pager/multiple pages).
Proposed resolution
Instead of taking the page number straight from the URL/request/query parameters, extract the current page number via the Views pager object.
Remaining tasks
Review and commit patch.
User interface changes
None.
API changes
None.
Comment | File | Size | Author |
---|---|---|---|
ds-view-alternating-view-modes-page.patch | 904 bytes | mr.baileys |
Comments
Comment #2
borisson_This looks like a really simple patch, great detective work there @mr.baileys. I've queued the testbots, when they come back green I think this can move to RTBC.
Comment #4
borisson_The tests don't seem to break on the latest commit, but this looks like it broke the tests quite hard.
\Drupal\views\ViewExecutable::getPager
should always return a plugin that extends\Drupal\views\Plugin\views\pager\PagerPluginBase
so I don't think that will be the problem.I don't see why this would break all those tests, but it looks like this patch did cause them.
Comment #5
borisson_Ah, it looks like the tests are broken in the same way in #3013746: Layout Attributes from textfield to textarea, so probably not this issues's fault. RTBC it is.
Comment #7
swentel CreditAttribution: swentel at eps & kaas for Dropsolid commentedWow, that's a cool one. You could have toggled "Use this configuration on every page. Otherwise the default view mode is used as soon as you browse away from the first page of this view." which would fix the behaviour you were seeing. However, I agree that the page check is nicer with that line :)
Committed and pushed, thanks!