When initially loading a view with infinite scroll, if a specific page is being requested in the URL we currently only load the items from that page. However, if you happen to have added something that updates the url / browser history when paging (e.g. Views AJAX History), then you would want to actually load all items up to the requested page.

So if you have a view set to limit to 10 items and you load ?page=2 you should get the contents of the first three pages for a total of 30 items.

Patch incoming!

Comments

drclaw created an issue. See original summary.

drclaw’s picture

Status: Active » Needs review
StatusFileSize
new3.76 KB

Here's a patch that adds an option to toggle the described functionality in the IS.

Status: Needs review » Needs work

The last submitted patch, 2: patch-initially_load_all_pages-2972129-0.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

drclaw’s picture

Status: Needs work » Needs review
StatusFileSize
new4.24 KB

Let's try this one...

drclaw’s picture

And one for the 8.x-1.5 people out there

drclaw’s picture

StatusFileSize
new4.17 KB

And here's one for 8.x-1.5 that doesn't break you site :/

divined’s picture

#6

it does not work. Aplied but nothing happens.

Loads last page items only, All previous are missing.

drclaw’s picture

Did you enable the setting on the view?

semanthis’s picture

I would desperately need something like this for D7. Anyone a idea where to start. Thanks!

drclaw’s picture

@semanthis Try Views Load More with this patch maybe? https://www.drupal.org/project/views_load_more/issues/2760451

ras-ben’s picture

#6 is brilliant - exactly what I needed and it works great

Karma for actually taking the time to make a real setting within the view UI too!

ras-ben’s picture

Status: Needs review » Reviewed & tested by the community
honza pobořil’s picture

Status: Reviewed & tested by the community » Needs work

Needs reroll.

biguzis’s picture

Status: Needs work » Needs review
StatusFileSize
new4.27 KB

Rerolled.

xaa’s picture

Patch #14 is working fine here. Thank you @biguzis, @drclaw.

If nothing happens (#7), don't forget the new checkbox in the view settings "Initially load all pages up to the reuqested page".

Maybe still need a bit of work on the description (quite long right now): "When initially loading a page beyond the first, this option will load all pages up to the requested page instead of just the requested page. So, if you have the pager set to 10 items per page, and you load the page with ?page=2 in the url, you will get page 0, 1 and 2 loaded for a total of 30 items. Note that this could cause some long page load times when loading many pages"

neslee canil pinto’s picture

Status: Needs review » Needs work

Everything looks fine and good, only change can we make a short and sweet description.

+        '#description' => $this->t('When initially loading a page beyond the first, this option will load all pages up to the requested page instead of just the requested page. So, if you have the pager set to 10 items per page, and you load the page with ?page=2 in the url, you will get page 0, 1 and 2 loaded for a total of 30 items. <em>Note that this could cause some long page load times when loading many pages</em>'),

neslee canil pinto’s picture

Status: Needs work » Fixed

Committed, Thanks everyone. This will be a good feature to have

YurkinPark’s picture

No ajax?

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

pratip.ghosh’s picture

I have a question somewhat similar to #19, why is the feature explicitly excluded for AJAX requests?

I can give a specific scenario here. Suppose I want to load a infinite scroll view via ajax upto a certain page. Due to this check it ignores this case. Is there a way to overcome this?