Needs review
Project:
Views Infinite Scroll
Version:
2.0.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Issue tags:
Reporter:
Created:
13 Feb 2017 at 12:07 UTC
Updated:
12 Aug 2026 at 10:13 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
andypostComment #3
andypostthis should be $this->t() because inside pluigin
Comment #4
tarasichThanks @andypost!
D7 habits)
Changed everywhere except static method
Comment #5
tarasichHide old one
Comment #9
andypostFix tests
Comment #12
tarasichComment #13
sam152 commentedThis seems pretty out of the 80% use case, for a module that already has a hard time keeping up with bare minimum compatibility with the rest of the views features and touch points. Maybe some test cases could be added to prove this works, but I can't say I really think this should be part of the base module.
We can use a number type here with a #min/#max?
Comment #14
diegodalr3 commentedFix offset option.
Comment #15
piggito commentedThis patch had an issue concerning pager, the default pager assumes all pages have the same number of elements. I added a getPagerTotal override method to solve this issue with the pager.
Comment #16
piggito commentedComment #17
sam152 commentedComment #18
Anonymous (not verified) commentedThis should be in the module. It's related to infinite pagers and shouldn't be fragmented off to its own world.
Comment #19
sam152 commentedI disagree. There is already a large volume of bugs and support requests that come up for the basic functionality. If the decision was made to allow every edge case into the module, it would be less maintainable than it already is. As of now, the functionality adds complexity, isn't tested and isn't appropriate for the 80%. Closing.
Comment #20
Anonymous (not verified) commentedHuh? You have people here requesting this as a feature. Closing this is really inappropriate.
Comment #21
andypostLet's set proper status - this issue no-go to becommited without tests
PS: I'm using the patch a lot and it works fine
Comment #22
sam152 commentedIt's actually a perfectly reasonable product management decision. Maintainer aren't obliged to commit feature requests.
Comment #23
waspper commentedAfter testing the patch, I've seen it works well. IMHO, it's a valid feature request for several use cases, keeping in mind that patch is almost ready.
I've tested it with several views, displaying ViewModes or Fields, and at least at my side, no errors found, with several Drupal versions.
Comment #24
skylord commentedSmall fix for edge cases in total items counting.
Comment #25
gaydamaka commentedFix patch after update dev version.
Comment #26
elamanAs it was stated before, this feature might be a game changer. Most of the people will module as it is, but there are times you need to show couple of items, then load much more.
I think it should also be possible to set initial number of values to zero. This could be used as "spoiler" feature to display attachments, etc.
Comment #27
nally commentedWe are seeing a client request for this specific case, so consider this an upvote for including it in the main version of the module if you do have the time.
Thanks for your maintenance efforts! We appreciate it.
Comment #28
renrhaf+1 : Using patch from #9, works perfectly on latest Drupal version.
This use case seems to be pretty useful for some people !
Thank you for your work on the cool module.
Comment #29
Anonymous (not verified) commentedFound a bug with patch from #9: If you have f. ex. 7 items, and you set the initially loaded items to 5, the load more link won't appear. E.a. if the number of remaining results is less than the "initial" setting introduced by this patch, you will not be able to fetch the last results.
Edit: This has been fixed with patch from #15.
Comment #30
YurkinPark commentedTests, updates for existing instances
Comment #31
YurkinPark commentedComment #32
andypostMinor codestyle fixes
Comment #33
tostinni commentedThank you for this patch, working fine and very useful.
However I noticed a small bug, if the views doesn't have enough items to load the first page, and the "initial items" variable is set to 0 to get the same number as the following pages then the load more button is shown even if there's no more pages.
Setting "initial items" to the same value as "Items to display" will fix this.
Also "Initial items" could be a number field instead of a text field.
Comment #34
honza pobořil commentedNice work.
I am going to commit it when this will be solved:
Comment #35
honza pobořil commentedComment #36
YurkinPark commented@bobík it is resolved now
Comment #37
Anonymous (not verified) commentedFound another bug with the latest patch (36): the @next_page_count token is incorrect if initial option is another other than zero. Updated patch attached.
Comment #38
Anonymous (not verified) commentedIt appears that in the latest version of Drupal (8.8.1) the getPagerTotal() method is no longer used. Therefore the calculation of the total number of pages is no longer correct. I've attached a new patch. Feel free to comment/improve.
Comment #39
andypostLast patch is broken, also please attach interdiff of you changes from 36 to help reviewers follow your changes
Comment #40
Anonymous (not verified) commentedsorry about that, I included the patch itself in my patch. attached should be correct patch.
Comment #41
Anonymous (not verified) commentedinterdiff
Comment #42
Anonymous (not verified) commentedAlso needed the functionality of #2667516 so I've added a patch that combines the latest patch in that issue and the one above.
Comment #43
Anonymous (not verified) commentedMade a mistake in patch above, here's a correct one. Again, this is only for when you need the functionality in issue #2667516 and the one from this ticket.
Comment #44
neslee canil pintoComment #45
maithri shetty commentedComment #46
maithri shetty commentedComment #47
maithri shetty commentedComment #48
YurkinPark commentedRerolled, need to provide tests to check how it works with #2972129: Add option to initially load all pages up to the requested page when loading pages beyond the first
Comment #49
YurkinPark commentedI think this is final version
Comment #50
mturner20 commentedI am on 8.8.x and patch #37 applied successfully!
Comment #51
lobodakyrylo commentedSince the last update different_item_count-2852080-49.patch doesn't work anymore. Here a new patch.
Comment #52
Anonymous (not verified) commentedHere's one that works with 1.8 and the latest patch of this issue: https://www.drupal.org/node/2667516
Comment #53
kevin.pfeifer commentedIs there a patch for D9.3 as well?
The patch from #52 can be applied and I see the new input field in the pager options but on AJAX Views this doesn't result in the desired behavior that I want to define a different amount of intially shown items vs the amount of items loaded after clicking the "Load more" button.
Comment #54
himanshu_jhaloya commentedHi I am looking patch for D9 is there any patch for this same issue version 2.0.1
Comment #55
himanshu_jhaloya commentedCreated patch for D9
Comment #56
erik_petra commentedPatch at #55 did not apply successfully for me through composer patches, so I fixed it and also fixed some formatting. Patch is for 2.0.2, due to Drupal 10 upgrades.
Comment #57
anybodyComment #58
christiansanders commentedUnfortunately the latest patch (comment #56) isn't working as desired.
I have a view with 9 results.
Initially set to display 7 and load 6 thereafter.
The initial items of 7 display, but because my view results don't have enough results to reach an additional 6 (9 results, 7 of initial page load, therefore 2 more to load in) the pager doesn't load.
I've tested by changing initially show 4 items and then 3 thereafter on load. The pager displays, loads in my 3, then no more pager, cause I have 2 items left, not 3.
This is all tested via AJAX.
Comment #59
christiansanders commentedAdded a patch that solves my comment in 58.
Comment #60
christiansanders commentedUploaded the files the wrong way around perviously - sorry!
Comment #61
christiansanders commentedComment #62
anybodyThanks @ChristianSanders could you prepare that as MR perhaps, please?
Comment #64
christiansanders commented@Anybody done - https://git.drupalcode.org/project/views_infinite_scroll/-/merge_request... (hope i've done this correctly - this is my first time contributing a patch via an MR!) Thanks :)
Comment #65
anybodyThanks @ChristianSanders. Looking quite good, but there is a conflict left. Perhaps it was based on an older branch? Could you resolve that one?
Here you can see the resulting diff from the MR: https://git.drupalcode.org/project/views_infinite_scroll/-/merge_request...
In the end it should be equal to your one?
Comment #66
himanshu_jhaloya commentedI was facing the same issue but checked with views_infinite_scroll-2852080-2852080-different-item-count this branch it is working fine for me thanks @christiansanders
Comment #67
anybodyThanks. So the last step here seems to be to add test coverage?
Comment #68
rsych commentedI checked the patch from #61, and there is another bug. My steps:
1. I set 6 items to show on load
2. I set 3 items to add on each "load more" click (I use the button)
Result: when I have 3 items in total, no "load more" button is shown (correct). But after creating another node, I have this behavior: it shows 4 nodes and (here's the error itself) the "load more" button. After clicking on this button, it disappears (without adding any item because everything is already displayed).
Comment #69
ypx commentedThis is an updated patch file to fix the bug reported at #68
The number of pages needs to be recalculated
When creating a pager we set total items = current_total_items + (items_per_page - initial_items).
Comment #71
damienmckennaI updated the merge request with the changes from #69 (and the latest changes from the 2.0.x branch).
In my local testing the new options work well, thank you all.
Comment #72
anybodyThanks, still needs tests (FunctionalJavascript) as last step, right? Who's our hero? 🦸🦸♀️
Comment #74
anneke_vde commentedI added a test for the different initial loading and after first page loading other amount.
Comment #76
mugesh.s commentedAlternative Implementation
Hi @all,
This approach provides another way to implement the feature without disturbing the current functionality.
Please review, test, and confirm if this works as expected.
I’ve also added test coverage to validate the behavior.
Issue Summary
This proposal adds a new “Page Control” feature to the Views Infinite Scroll pager plugin, allowing site builders to specify different item counts for:
This is useful in UX scenarios where the first page of a listing (e.g., landing pages or featured sections) should show fewer or more items than the rest.
Proposed resolution
Enable Page Controlin the pager settings.Items per pagefield.Items for the first pageItems for the other pagesgetRemainingItems()andgetNumberItemsLeft()methods to reflect accurate counts.#stateslogic in the options form for dynamic field visibility.User interface changes
A new checkbox and two conditional number fields will be shown in the Views UI under the pager settings.
Example Use Case
Video Demonstration
Here’s a working demo of the feature implemented on my site:


This feature has been implemented in the branch:
2852080-Add-Page-ControlA patch has also been attached here for testing.
✅ Please review and test the patch and merge request.
💬 Feedback and suggestions are most welcome!
Comment #78
mugesh.s commentedUse
Add-Page-Control-2852080-#78.patchthis patch to avoid warning errors.Comment #79
weareronin commentedSuccessfully tested patch #78 in our project. Thanks !
Comment #81
herved commentedRebased the MR and added a few changes/fixes on top:
default:key from the config schema.initialitems with no way to load the rest).