Skip to:
Content
Pages
Categories
Search
Top
Bottom

Detecting if you are on a specific sub nav


  • modemlooper
    Moderator

    @modemlooper

    I know there is this to find components
    if ( bp_is_page( BP_MEMBERS_SLUG ) || bp_is_member() )

    but what is code to detect which profile subnav you are on? May just use jquery to detect clicks :P

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

  • Boris
    Participant

    @travel-junkie

    You can use the $bp global, so for example this:
    `if( $bp->current_component == BP_MEMBERS_SLUG && $bp->current_action == ‘subnav-slug’ && $bp->action_variables[0] == ‘subnav-variable’ )
    {
    // do something
    }`


    modemlooper
    Moderator

    @modemlooper

    That didn’t work.


    modemlooper
    Moderator

    @modemlooper

    Here’s something else I was trying to create. This would be great for theme devs. Basically wanted to merge the user nav and subnav together. This code works great but I’m not sure how to only show the subnav when on the parent user nav. This code just outputs everything. I got as far as showing only the first link by wrapping echo in an if statement because when you click a parent link you are in essence on the firs subnav.

    http://pastebin.com/LCW3wsZ9


    Boris
    Participant

    @travel-junkie

    Well, it should work. What’s the exact code you were using?

    Also, it’s worth noting that the `$bp` global behaves a bit differently when on a member page. Take this for example:
    https://buddypress.org/community/members/username/settings/

    `$bp->current_component` wouldn’t be members, as you might expect, but settings. In that case you could check for `$bp->displayed_user->id`.


    modemlooper
    Moderator

    @modemlooper

    To test, I used it to just echo a string if on the profile of a members page.

    I’m using it on a member page not members direectory. Taking the user nav and the sub nav and putting it into a sidebar so when you click profile on the user nav the get options nav shows underneath.

    bp-default has 2 separate navs and calls the options nav depending on the user nav. I want to mush that into one nav.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Detecting if you are on a specific sub nav’ is closed to new replies.
Skip to toolbar