Tip: improve top nav – add My Profile which includes activity and profile
-
This is just a quick hint on how to improve the top navigation to be more user friendly. (and more similar to facebook, which people are familiar with)
The top nav in the new BuddyPress theme is great. I love the simple rounded tabs. I like the very admin bar as well, but it is hidden, so new users don’t see it right away. I replaced the top Activity tag with My Profile and linked this page to the My Account page, thereby quickly giving users the ability to see all their settings and activity in one place.
you first need to create a child theme if you’ve not already done so. Any live site will want to look different and use a child theme. There is a great tutorial on how to do that here: http://codex.buddypress.org/how-to-guides/building-a-buddypress-child-theme/
next edit the header.php in your child theme.
find the 6 lines of code pertaining to the activity tab starting on line 51:
<?php if ( 'activity' != bp_dtheme_page_on_front() && bp_is_active( 'activity' ) ) : ?>
replace that 6 line chunk with this
<li<?php if ( bp_loggedin_user_id() == bp_displayed_user_id() ) : ?> class="selected"<?php endif; ?>>
<a href="<?php echo bp_loggedin_user_domain() ?>" title="<?php _e( 'My Profile', 'buddypress' ) ?>"><?php _e( 'My Profile', 'buddypress' ) ?></a>
</li>edit the name of the tab in the above code as you see fit, maybe you want ‘My Account’ or ‘Activity & Profile’ whatever.
finally, a little further down, change this line
<li<?php if ( bp_is_page( BP_GROUPS_SLUG ) || bp_is_group() ) : ?> class="selected"<?php endif; ?>>
to
<li<?php if ( ( bp_is_page( BP_MEMBERS_SLUG ) || bp_is_member() ) && ( bp_loggedin_user_id() != bp_displayed_user_id() ) ) : ?> class="selected"<?php endif; ?>>
that just makes it so that two tabs are not highlighted at the same time.
enjoy.
-
CORRECTION to work well with logged-out users:
the first chunk should contain an if statement to only show the My Profile if the user is logged in:
<?php if ( bp_loggedin_user_id() ) : ?>
<li<?php if ( bp_loggedin_user_id() == bp_displayed_user_id() ) : ?> class="selected"<?php endif; ?>>
<a href="<?php echo bp_loggedin_user_domain() ?>" title="<?php _e( 'My Profile', 'buddypress' ) ?>"><?php _e( 'My Profile', 'buddypress' ) ?></a>
</li>
<?php endif; ?>and the second part for the members section should be this line, instead of the line I mentioned above:
<li<?php if ( ( bp_is_page( BP_MEMBERS_SLUG ) || bp_is_member() ) && ( bp_loggedin_user_id() != bp_displayed_user_id() || !bp_loggedin_user_id() ) ) : ?> class="selected"<?php endif; ?>>
I’ve done this tip to my own child theme, Dwenaus.
I might be using a slight variation on what you posted though.
hey, let me know if you find improvements. post ’em here if you do
Here’s what I’m using for:
My Profile tab:
<?php if(is_user_logged_in()) : ?>
<li<?php if ( bp_is_my_profile() ): ?> class="selected"<?php endif; ?>>
<a href="<?php echo bp_get_loggedin_user_link(); ?>" title="<?php _e( 'My Profile', 'buddypress' ) ?>"><?php _e( 'My Profile', 'buddypress' ) ?></a>
</li>
<?php endif; ?>Members tab:
<li<?php if ( bp_is_page( BP_MEMBERS_SLUG ) || bp_is_member() && !bp_is_my_profile()) : ?> class="selected"<?php endif; ?>>
<a href="<?php echo site_url() ?>/<?php echo BP_MEMBERS_SLUG ?>/" title="<?php _e( 'Members', 'buddypress' ) ?>"><?php _e( 'Members', 'buddypress' ) ?></a>
</li>Slightly simpler than yours. But if there’s an even, simpler way let me know!
interesting idea.
Could you please provide a Screenshot of how this looks like ?
Many thanks
here is an image:
- The topic ‘Tip: improve top nav – add My Profile which includes activity and profile’ is closed to new replies.