Allow the next page url to be rewritten

Created on 12 July 2023, 12 months ago
Updated 17 August 2023, 11 months ago

Problem/Motivation

Hi! I'm working on a feature where I need to change the "Load more items" button URL, I don't know if I'm doing it the best way but right now it's working properly. Just for you know, I have a custom module with the following snippet implemented:

/**
 * Implements hook_preprocess_views_infinite_scroll_pager().
 */
function my_custom_module_preprocess_views_infinite_scroll_pager(&$vars) {
  $vars['items']['next']['href'] = Url::fromRoute('/custom-path');
}

The only problem is, my custom hook is being executed before the views_infinite_scroll_preprocess_views_infinite_scroll_pager so every time, my custom URL is being rewritten, and I couldn't find any way to change the preprocess hook order(if you know how to do it, please tell me, I've tried to use the hook_module_implements_alter hook, but it's not working)

Proposed resolution

Change the views_infinite_scroll_preprocess_views_infinite_scroll_pager to change the URL only if the $vars['items']['next']['href'] is empty

Remaining tasks

  1. Review
  2. Commit
✨ Feature request
Status

Needs review

Version

2.0

Component

Code

Created by

πŸ‡§πŸ‡·Brazil murilohp

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024