Skip to:

Opened 14 years ago

Closed 14 years ago

#1501 closed defect (bug) (worksforme)

Main nav slugs incorrect while browsing user blogs (easy fix)

Reported by: teebes's profile teebes Owned by:
Milestone: 1.2 Priority: minor
Severity: Version:
Component: Keywords: main nav
Cc: mercime


The main nav items (Home, Blogs, Groups, etc) are not linked correctly on a subdirectory<user>/blog type install. The links are maintaining the user's context in the URL. You can try this by comparing: (works fine at highest level) vs a user's blog: (doesn't link).

In header.php, it looks like we might simply need to replace site_url() with bp_home_blog_url() on the various nav items as that works correctly. I'm not sure if there is a preference to a different variable that may exist out there, so I wont submit code.

Thanks :)

Change History (3)

#1 @DJPaul
14 years ago

  • Priority changed from critical to major

The default BuddyPress theme only works correctly (specifically this navigation menu links) on the main blog of a site; the URLs will break when used on hosted blogs. It's always been like this however a solution like you propose is interesting.

I would class this as an enhancement rather than a defect but am leaving it as-is so it is reviewed by a committer before BP 1.2 as it's not a complicated change.

#2 @mercime
14 years ago

  • Cc mercime added
  • Priority changed from major to minor

Use WPMU's native switch_to_blog and restore_current_blog functions to get the navigation of main site with the correct URL's. Done the method below or a variation thereof for my installs of WPMU used as CMS.

Code for sub-blog's theme:

<ul id="nav"
<?php switch_to_blog('1') ?>
//copy the navigation code from header.php of either bp-default/bp-sn-parent theme
//or the code used in main site plus any customized links you added in main site
<?php do_action( 'bp_nav_items' ); ?>
<?php restore_current_blog(); ?>

#3 @apeatling
14 years ago

  • Resolution set to worksforme
  • Status changed from new to closed

You can add this to your wp-config.php file to enable the theme to work on any sub blog:

define( "BP_ENABLE_MULTIBLOG", true );

You should avoid using switch_to_blog() since it is very slow and expensive.

Note: See TracTickets for help on using tickets.