Skip to:
Content
Pages
Categories
Search
Top
Bottom

Make MyGroups the default directory listing


  • rgilman
    Participant

    @rgilman

    I’m developing my own theme based on BP-Nouveau. I’d like the default groups-directory listing under the Groups component to be of the displayed user’s groups (i.e. My Groups). I’d like to make the second nav choice be all groups that the displayed user isn’t part of. I’ve been poking around in the code but feel stumped. Any pointers on these two items would be most welcome.

    I’m on WP 5.1.1 and BP 4.2.0. Since this is on my local dev machine, I don’t have a link to the site.

    Thanks!

Viewing 12 replies - 1 through 12 (of 12 total)

  • shanebp
    Moderator

    @shanebp

    You can use this filter hook:
    apply_filters( 'bp_nouveau_get_groups_directory_nav_items', $nav_items );
    Found in: buddypress\bp-templates\bp-nouveau\includes\groups\functions.php

    You can definitely add a nav item with that hook.
    And you should be able to reorder the existing items.

    Take a look at the nav item structure:

    function pp_groups_dir_nav  ( $nav ) {
        echo '<pre>'; var_dump( $nav ); echo '</pre>';
        return $nav;
    }
    add_filter( 'bp_nouveau_get_groups_directory_nav_items', 'pp_groups_dir_nav' ); 

    But you are writing a custom theme, so it would be easier to write a custom function to replace
    function bp_nouveau_get_groups_directory_nav_items rather than filter the current output.


    rgilman
    Participant

    @rgilman

    @shanebp, thanks for responding. Apologies if my language was confusing. You are right that I mean the Groups component directory and not the member profile page.

    My users are primarily interested in navigating to their existing groups. Only occasionally will they want to explore other groups. I’d like to eliminate the extra step and distraction of the current tab order.

    Anyone else have any ideas about how to change the tab order on the Groups Directory page in Nouveau?

    I just discovered that if I select the My Groups tab, go away from the /groups/ page and then return to it, it retains the My Groups tab as the active tab. I wonder if there is a way to force this?


    rgilman
    Participant

    @rgilman

    Looks like we were writing in parallel! I’ll see what I can do with your edited response.


    rgilman
    Participant

    @rgilman

    @shanebp, hooking into ‘bp_nouveau_get_groups_directory_nav_items’ works well to modify the nav items (thanks for that).

    For testing purposes, I’ve created an ‘Others’ tab which is intended to display the groups that the member does not belong to. It links out to an ‘others.php’ template file but I haven’t been able to get this new nav item to do anything. Rather, it just duplicates the behavior of the ‘All Groups’ tab. I suspect I’m missing something that hooks into the AJAX process. Might @imath be some help with this as the creator of bp-nouveau?


    shanebp
    Moderator

    @shanebp

    imath might respond, but it is unlikely. They are rarely on these forums.

    You’ll need to walk thru the code to see every step of how other tabs are handled.
    I would look at the My Groups code.
    It may well be an ajax issue.

    If you find a solution, please update this topic.


    shanebp
    Moderator

    @shanebp

    btw – when you dump the $nav items to the screen, did you notice that the Create array includes a no-ajax entry?
    Perhaps get that working and then try an ajax solution.


    rgilman
    Participant

    @rgilman

    Thanks again for your response. I did notice the no-ajax entry. I’ll dig into the My Groups code and see what I can find. If I find a solution, I update this topic.


    rgilman
    Participant

    @rgilman

    I’ve got this sorted out. I filter bp_nouveau_get_groups_directory_nav_items to unset $nav[‘all’], adjust the properties of $nav[‘personal’] so it’s selected and first, get the group counts for My Groups and Other Groups, and specify the properties of $nav[‘others’]

    I also filter bp_nouveau_ajax_querystring to query for the ‘others’ list.

    I’ve created a gist with the code.


    shanebp
    Moderator

    @shanebp

    Thanks for the follow-up and the gist!
    Remember – you can always add a page to the codex too.


    larnoult
    Participant

    @larnoult

    Hey @rgilman,
    Very interested by the gist! Unfortunately it’s not available anymore 🙁
    Thanks!


    sasasasaaa
    Participant

    @sasasasaaa

    @rgilman gist is not available anymore and I tried myself to fix it with very little php knowledge and got nowhere. Do you might like to share it here? Thanks


    sasasasaaa
    Participant

    @sasasasaaa

    Or maybe somebody else can help.

    How can I modify ‘bp_nouveau_get_groups_directory_nav_items’ with apply_filter to make “my-groups” default in directory listing?

Viewing 12 replies - 1 through 12 (of 12 total)
  • You must be logged in to reply to this topic.
Skip to toolbar