Skip to:
Content

BuddyPress.org

Opened 13 years ago

Closed 13 years ago

#3679 closed enhancement (fixed)

Multiple loops and pagination variable collision

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

Description

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 13 years ago.
3679.activity.01.diff (3.0 KB) - added by cnorris23 13 years ago.
Activity
3679.blogs.01.diff (3.1 KB) - added by cnorris23 13 years ago.
Blogs
3679.groups.01.diff (3.2 KB) - added by cnorris23 13 years ago.
Groups
3679.members.01.diff (2.8 KB) - added by cnorris23 13 years ago.
Members
3679.messages.01.diff (2.9 KB) - added by cnorris23 13 years ago.
Messages

Download all attachments as: .zip

Change History (18)

@r-a-y
13 years ago

#1 @r-a-y
13 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' ) ) : ?>

#2 @cnorris23
13 years ago

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

#3 @cnorris23
13 years ago

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

#4 @DJPaul
13 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 13 years ago by DJPaul (previous) (diff)

#5 @DJPaul
13 years ago

  • Milestone changed from Awaiting Review to 1.6

#6 @anointed
13 years ago

  • Cc anointed added

#7 @boonebgorges
13 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.

#8 @johnjamesjacoby
13 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.

@cnorris23
13 years ago

Activity

@cnorris23
13 years ago

Blogs

@cnorris23
13 years ago

Groups

@cnorris23
13 years ago

Members

@cnorris23
13 years ago

Messages

#9 @cnorris23
13 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?

#10 @DJPaul
13 years ago

  • Milestone changed from Future Release to 1.6

#11 @DJPaul
13 years ago

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

#12 @djpaul
13 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.