Skip to:
Content

BuddyPress.org

Opened 12 years ago

Closed 9 years ago

#2242 closed enhancement (wontfix)

make Group sticky

Reported by: erich73's profile erich73 Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Groups Keywords: has-patch needs-testing 2nd-opinion
Cc: math.viet@…

Description

I do have a couple thousand groups.

Please make it possible to make a certain Group "sticky" at the top of the Groups-List.
Even better to be able to make a certain Group "sticky" within a Group-Category.

Thanks,

Attachments (1)

2242.diff (20.9 KB) - added by imath 9 years ago.

Download all attachments as: .zip

Change History (12)

#1 @boonebgorges
12 years ago

  • Milestone changed from 1.3 to Awaiting Review

#2 @DJPaul
11 years ago

  • Milestone changed from Awaiting Review to 1.4

Interesting idea but I don't think there will be time left for this in 1.3 as we'll have to rewrite the query in the get groups function.

#3 @Dennissmolek
11 years ago

I wanted to note in this that it is possible to run your own group loop and pull whatever group ID you wanted. You would just use a child theme group list page. for a few groups it would be no big deal, annoying if you had a bunch though. I dont know if this needs a BP level fix though, as it is done easy enough now..

#4 @DJPaul
11 years ago

  • Milestone changed from 1.6 to Future Release
  • Severity set to normal

#5 @imath
9 years ago

  • Cc math.viet@… added
  • Keywords has-patch needs-testing added

Hi,

I've worked on the first part of the ticket : stick one or more groups on top of the first page of the Groups Directory.

The patch (2242.diff) first adds a settings option to BuddyPress main settings page to activate/deactivate sticky groups (see http://flic.kr/p/fDew1Y)
Then if this settings is set and the group status is not hidden, a new checkbox will appear in the WordPress backend Group Admin UI when viewing a single group just above the privacy settings of the group (see http://flic.kr/p/fDew1G).
Then if groups are sticked to the top of the Groups Directory, they will be displayed first then the other groups will be displayed (see http://flic.kr/p/fCWXqK).
In the WordPress backend Group Admin UI when viewing all groups, sticky ones have a yellow background (see http://flic.kr/p/fDew1A).

Now Sticky groups are displayed on top if :

  • we're on the first page of the Groups Directory
  • no search query have been sent > i think a group that don't match the query but shows is an annoying behavior
  • no user id have been sent > in this case, we're not in groups directory
  • no include group have been sent > in this case, the user wants the included groups, not the sticky ones.

I needed to use the function round() for the groups pagination as playing with floats and integer gave me some weird results...
for instance :
intval( (1.4 - 1) * 5 ) gives 1
but intval( round( (1.4 - 1) * 5 ) ) gives 2 (and i think it's the correct result ;) )

@imath
9 years ago

#6 follow-up: @boonebgorges
9 years ago

  • Keywords 2nd-opinion added

imath - I've had a look at this patch, and I think it's kinda cool, but I'm pretty skeptical about the utility of having sticky groups as a core feature. A couple questions:

1) imath - are the hooks and filters in place to make a plugin that does this?
2) others - do you think that this is of broad enough interest to attempt to include in BP core?

#7 in reply to: ↑ 6 @imath
9 years ago

Replying to boonebgorges:

1) imath - are the hooks and filters in place to make a plugin that does this?

Well i think as the main challenge of this patch is group pagination and first excluding sticky to then put them on top, what can be useful for a plugin is to easily have the arguments of BP_Groups_Group::get()

so in 'bp_groups_get_paged_groups_sql' filter at line 444 of bp-group-classes.php, i would add them after the $sql argument

eg:
apply_filters( 'bp_groups_get_paged_groups_sql', join( ' ', (array) $sql ), $sql, $r );

then, after a quick look, by filtering 'bp_has_groups' its possible to merge $groups_template with sticky groups (if put in a buddypress() instance var or a global) if on first page as this filter includes the arguments of bp_has_groups() function (in bp-groups-template.php).

But it could be convenient to merge this data before by adding a filter at line 516 of bp-groups-classes.php

eg:
return apply_filters( 'bp_groups_return_paged_groups', array( 'groups' => $paged_groups, 'total' => $total_groups ), $r );

finally, to include a specific style to a sticky group, i guess it needs a specific template tag reason why the patch has included one (bp_groups_group_class())

I understand you're skeptical about the utility to add this in core, i have doubts too. I've made a quick search and found no plugin doing so, at the same time i've heard people requesting this feature at several occasions.. (same for members actually)

#8 follow-up: @boonebgorges
9 years ago

Thanks for the thoughful response, imath.

what can be useful for a plugin is to easily have the arguments of BP_Groups_Group::get()

Agreed. This would be useful for many reasons. I'm going to add it immediately.

convenient to merge this data before by adding a filter at line 516 of bp-groups-classes.php

I'm wary of adding this kind of filter without first thinking about an overall filtering strategy for all components with the rest of the team. Since you can modify $groups_template directly, please go ahead and use this technique for now.

to include a specific style to a sticky group, i guess it needs a specific template tag reason why the patch has included one (bp_groups_group_class())

Could you please submit a patch with just this feature? It shouldn't be a problem to add it.

Once these changes are in place, I'm leaning toward closing this ticket as wontfix for now. I encourage you to build the feature as a plugin, and put it out there to see if people use it and love it. I agree that the most elegant place to do stickies is in core, but I don't want to take on the extra baggage if we don't have good reason to believe that many people will use it. If it turns out that your plugin is wildly popular, we can reopen this ticket and reconsider. Does that sound reasonable?

#9 in reply to: ↑ 8 @imath
9 years ago

Replying to boonebgorges:

Does that sound reasonable?

Absolutely ;)

I'll publish a plugin on github asap !

#10 @imath
9 years ago

Finally, i've changed my mind ! I've just published a plugin request to WordPress.org repo (bp-sticky-groups). It will be easier this way to see if the sticky feature is popular thanks to the downloads stats.

I also thought adding a template tag to style the sticky group was a bit too much, so i'm filtering the group name.

#11 @boonebgorges
9 years ago

  • Milestone Future Release deleted
  • Resolution set to wontfix
  • Status changed from new to closed

Excellent. Thanks, imath!

Note: See TracTickets for help on using tickets.