#4071 closed enhancement (fixed)
Changes to allow for completely seperate group types
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | 1.6 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Groups | Keywords: | has-patch |
Cc: |
Description
Having various group types is currently possible. Having a unique URL for these group types is not, however.
I am currently writing a plugin that needs this, though. So for normal user groups I'd normally have an URL like so:
http://my-site.com/groups/group-slug/
For various group types I would then need an URL like this:
http://my-site.com/group-type/group-slug/
To make this happen I've had to add various filters and change the bp_group_admin_tabs() function to use bp_get_group_permalink(), so the link can be filtered.
It also became necessary to filter out some group types from the normal groups directory. I've noticed an inconsistency when filtering 'bp_groups_get_total_groups_sql' (line 387 in bp-groups-classes.php in trunk). $t_sql is already cast as a string, but is then being cast as an array again and then joined to create a string, which is unnecessary. Then $t_sql is also passed as the second argument to the filter, which doesn't make much sense. It would be better if $total_sql is passed instead.
The group count for users then obviously needs adjusting as well, which is currently not possible with 'bp_get_total_group_count_for_user' (line 1666 in bp-groups-template.php). $user_id should really be passed as a second argument to the filter to make this possible.
Please see the attached patch files.
There might be other instances where a filter is needed. I'll add these filters to the ticket if I come across it during development.
Attachments (1)
Change History (6)
#2
@
13 years ago
There's nothing fancy, really. I just filter a bunch of links by checking against group meta, remove all group types but the normal user groups from the groups directory (and then create their own directories) and then reset the current component to groups with something like this function:
function setup_single_spheres() { global $bp; if( bp_is_current_component( 'spheres' ) && bp_current_action() ) : $bp->current_component = 'groups'; endif; } add_action( 'bp_setup_globals', 'setup_single_spheres', 0 );
Not sure how much of the code I'm allowed to share as it's a commercial contract. I'll get in contact with my clients. It's all pretty straightforward, though.
#3
@
13 years ago
- Milestone changed from Awaiting Review to 1.6
Thanks, travel-junkie - this is helpful. I was just mainly curious about how you were doing it, and the bp_setup_globals stuff is the key, so thanks for that :)
I have made several improvements to your patch. The main point is that links should, whenever possible, be constructed with bp_get_group_permalink(). Your patch repaired this in bp_group_admin_tabs(), but elsewhere you just added new filters. I've corrected that, so it should be possible for you just to filter 'bp_get_group_permalink'. (If I've missed any spots, let me know.)
The changes to filters all look good.
Thanks for the patch.
#4
@
13 years ago
- Resolution set to fixed
- Status changed from new to closed
(In [5903]) Improvements to link construction and filters in the Groups component:
- Fixes arguments being passed to bp_groups_get_total_groups_sql filter
- Passes additional arguments to various group link filters
- Sweeps through link concatenation in the groups component, to ensure that bp_get_group_permalink is used wherever possible (allowing for centralized filters in plugins)
- Corrects some inline documentation
- Fixes the permissions logic in bp_groups_adminbar_admin_menu(), so that super admins and group admins are able to see the group-specific dropdown when using the BuddyBar
- Fixes #4071. Props travel-junkie
Thanks for the patch, travel-junkie. I think this is an interesting idea. If you've got it handy, and in a sharable form, would you mind also posting the plugin code that you're using to test this patch? (or at least the relevant pieces) Obviously you are filtering some link values, but I want to see if there's anything else fancy that you're doing.