Group Types option display
-
i need some advice or help about the following function. (i use BP 2.7 RC2)
While it display correctly a list of all typed groups, i want also that all different types stays together.
The list is sorting by alphatetical order group names as expected, but it seems more logic to get such a list sorted by types first – as we use a cutom group directory filter “by types”
To be clear, what i expect it this when i click on Order by: Types
Type A
– group 1
– group 2Type B
– group 1 (has 2 types allocated)
– group 3
– group 4Type C
…
and so on.I’m unable to add any array sort (or better i don’t know how to write the correct one) for this. I also haven’t found a BP filter (if exist)…
If somebody could tell me how to achieve this, it would be great ! (@boonebgorges, @r-a-y, @ ….)
// add a filter option on group directory function bpex_group_order_options() { if( bp_is_active( 'groups' ) && bp_is_groups_directory() ) { ?> <option value="gtype"><?php _e( 'Types', 'buddypress' ); ?></option> <?php } } add_action( 'bp_groups_directory_order_options', 'bpex_group_order_options' ); // my problem is with this function: //ajax query for group types function bpex_group_types_filter_ajax_querystring( $querystring = '', $object = '' ) { if( $object != 'groups' ) return $querystring; $defaults = array('type' => 'active' ); $bpex_querystring = wp_parse_args( $querystring, $defaults ); if( $bpex_querystring['type'] != 'gtype' ) return $querystring; // query types $q_types = bp_groups_get_group_types(); $bpex_querystring = array( 'group_type' => $q_types ); $bpex_querystring['type'] = 'alphabetical'; return apply_filters( 'bpex_gtq_filter_ajax_querystring', $bpex_querystring, $querystring ); } add_filter( 'bp_ajax_querystring', 'bpex_group_types_filter_ajax_querystring', 20, 2 );
For those interested by extending their group directory for types, i wrote a tutorial (in french) with all snippets to get a tab for each type, displayable on the main group nav or on the new group type nav bar.
If you use the tabed types display, you don’t really need a the filter option to check only for typed groups. But if you don’t want tabs more tabs, by lack place or whatever, you may want to access them via the group directory filter.
- You must be logged in to reply to this topic.