Skip to:

Opened 4 years ago

Closed 4 years ago

#3679 closed enhancement (fixed)

Multiple loops and pagination variable collision

Reported by: r-a-y Owned by:
Milestone: 1.6 Priority: normal
Severity: normal Version: 1.2
Component: Component - Core Keywords: has-patch
Cc: anointed


If you attempt to use multiple loops of the same component with pagination, the loops will not be independent of one another.

One way to work around this is to introduce a new parameter that we can set in the loop.

Then, the constructor that populates the loop will use this parameter as the query arg in pagination_links().

I've attached a patch detailing how this might work with the members loop.

The hope is that this approach will be used for all BP loops.

Attachments (6)

3679.01.patch (3.1 KB) - added by r-a-y 4 years ago.
3679.activity.01.diff (3.0 KB) - added by cnorris23 4 years ago.
3679.blogs.01.diff (3.1 KB) - added by cnorris23 4 years ago.
3679.groups.01.diff (3.2 KB) - added by cnorris23 4 years ago.
3679.members.01.diff (2.8 KB) - added by cnorris23 4 years ago.
3679.messages.01.diff (2.9 KB) - added by cnorris23 4 years ago.

Download all attachments as: .zip

Change History (18)

@r-a-y4 years ago

comment:1 @r-a-y4 years ago

So if you use a default members loop and you want another loop independent of the current one, you could use something like:

<?php if ( bp_has_members( 'page_arg=members&per_page=5' ) ) : ?>

comment:2 @cnorris234 years ago

Does using bp_rewind_members() after the first loop not work either?

comment:3 @cnorris234 years ago

Nevermind. I just looked closer. bp_rewind_members() wouldn't do anything for this.

comment:4 @DJPaul4 years ago

Looks good, go ahead and patch for the other loops, please. Only thing I'd change is adding a default value to that new class constructor argument, for backpat.

Last edited 4 years ago by DJPaul (previous) (diff)

comment:5 @DJPaul4 years ago

  • Milestone changed from Awaiting Review to 1.6

comment:6 @anointed4 years ago

  • Cc anointed added

comment:7 @boonebgorges4 years ago

  • Keywords needs-refresh added

The approach in this patch is fine, but we do need a refresh that will give a default value, as DJPaul suggested. r-a-y, can you do that for us? Can still squeeze this into 1.6, as there shouldn't be any other backpat issues and it's a straightforward enhancement.

comment:8 @johnjamesjacoby4 years ago

  • Milestone changed from 1.6 to Future Release

It's getting late to squeeze this in for 1.6. It'd be great to do the same for all of the loops, not just members. Groups, Activity, etc...

Moving to Future Release; feel free to patch and move back to 1.6. Boone/Paul - if a good patch comes around, commit it asap so we can test it out.

@cnorris234 years ago


@cnorris234 years ago


@cnorris234 years ago


@cnorris234 years ago


@cnorris234 years ago


comment:9 @cnorris234 years ago

  • Keywords needs-refresh removed

Refreshed original patch, and patched other loops with pagination, with forums being the exception. I went a la carte to so one can craft their ideal pagination variable collision prevention scenario.

I also noticed that in the template classes, we're inconsistent with PHP 4 contructors, or lack thereof. Three of the five I patched have PHP 4 constructors. Are these still needed, or should we start cleaning them out?

comment:10 @DJPaul4 years ago

  • Milestone changed from Future Release to 1.6

comment:11 @DJPaul4 years ago

Thanks for the patches. And yes, we're removing the PHP4 constructors.

comment:12 @djpaul4 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [5891]) Allow pagination arguments for template loops to be renamed. Remove PHP4 constructors. Fixes #3679, props r-a-y and cnorris23

Note: See TracTickets for help on using tickets.