Skip to:
Content
Pages
Categories
Search
Top
Bottom

Main Navigation help

  • Avatar of chrisknade
    chrisknade
    Participant

    @chrisknade

    I’m getting to the end of development and one of the things that has been a constant issue is that I’ve got the following code :

    <ul id="nav">
    <li<?php if ( bp_is_page( 'home' ) ) : ?> class="selected"<?php endif; ?>>
    <a href="<?php echo get_option('home') ?>" title="<?php _e( 'Home', 'buddypress' ) ?>"><?php _e( '// Home', 'buddypress' ) ?></a>
    </li>
    <li<?php if ( bp_is_page( BP_HOME_BLOG_SLUG ) ) {?> class="selected"<?php } ?>><a href="<?php echo get_option('home') ?>/<?php echo BP_HOME_BLOG_SLUG ?>" title="<?php _e( 'News', 'buddypress' ) ?>"><?php _e( '// News', 'buddypress' ) ?></a></li>
    <li<?php if ( is_page('local-networks') ) {?> class="selected"<?php } ?>><a href="<?php bloginfo('url'); ?>/local-networks" title="<?php _e( 'Local Networks', 'buddypress' ) ?>"><?php _e( '// Local Networks', 'buddypress' ) ?></a></li>
    <?php if ( function_exists( 'groups_install' ) ) { ?>
    <li<?php if ( bp_is_page( BP_GROUPS_SLUG ) ) {?> class="selected"<?php } ?>><a href="<?php echo get_option('home') ?>/<?php echo BP_GROUPS_SLUG ?>" title="<?php _e( 'Groups', 'buddypress' ) ?>"><?php _e( '// Groups', 'buddypress' ) ?></a></li>
    <?php } ?>
    <li <?php if ( bp_is_page( BP_MEMBERS_SLUG ) ) {?> class="selected"<?php } ?>><a href="<?php echo get_option('home') ?>/<?php echo BP_MEMBERS_SLUG ?>" title="<?php _e( 'Members', 'buddypress' ) ?>"><?php _e( '// Members', 'buddypress' ) ?></a></li>
    <?php if ( function_exists( 'bp_blogs_install' ) ) { ?>
    <li<?php if ( bp_is_page( BP_BLOGS_SLUG ) ) {?> class="selected"<?php } ?>><a href="<?php echo get_option('home') ?>/<?php echo BP_BLOGS_SLUG ?>" title="<?php _e( 'Blogs', 'buddypress' ) ?>"><?php _e( '// Blogs', 'buddypress' ) ?></a></li>
    <?php } ?>
    <li><a href="<?php echo get_option('home') ?>/forums" title="<?php _e( 'Forums', 'buddypress' ) ?>"><?php _e( '// Forums', 'buddypress' ) ?></a></li>

    <li<?php if (is_page('services') ) {?> class="selected"<?php } ?>><a href="<?php bloginfo('url'); ?>/services" title="<?php _e( 'Services', 'buddypress' ) ?>"><?php _e( '// Services', 'buddypress' ) ?></a></li>

    <?php do_action( 'bp_nav_items' ); ?>
    </ul>

    As you can see I’ve got a members page, problem is if I go to the services or the local networks page, the members is highlighted too, Any ideas why this would do that, as Im pretty sure the logic is right?

    Cheers

    Chris

Viewing 4 replies - 1 through 4 (of 4 total)
  • Avatar of Peterverkooijen
    peterverkooijen
    Participant

    @peterverkooijen

    I just wrestled with that issue here.

    A ‘members’ class was added to the body tag on pages under groups and blogs. BP_MEMBERS_SLUG or $bp->current_component are not very “precise” I guess.

    I wasn’t able to figure out why this happens. I managed to get it to work, sort of, with the combination of lines in my custom function for the navigation.

    Avatar of chrisknade
    chrisknade
    Participant

    @chrisknade

    So what did you end up using from that other post?

    Just this in the header?

    if ( $bp->current_component == 'activity' || $bp->current_component == 'profile' || $bp->current_component == 'wire' || $bp->current_component == 'messages' || $bp->current_component == 'friends')
    $c[] = 'members';

    if ( bp_is_page( BP_MEMBERS_SLUG ) )
    $c[] = 'members';

    Avatar of Peterverkooijen
    peterverkooijen
    Participant

    @peterverkooijen

    No, not in the header; in a function that puts classes in the body tag and then you can use those classes to highlight current in CSS.

    So in my theme I have something like this in header.php:

    <body class="<?php custom_body_class() ?>">

    And then a function custom_body_class in functions.php in the theme.

    It’s a different approach, but I noticed the same problem with ‘members’ getting added to just about any body tag. I wasn’t able to figure out why, but managed to sort of make it work by throwing the kitchen sink at it.

    I know, not very helpful…

    Avatar of Peterverkooijen
    peterverkooijen
    Participant

    @peterverkooijen

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

The topic ‘Main Navigation help’ is closed to new replies.