Skip to:
Content

BuddyPress.org

Opened 10 years ago

Closed 10 years ago

#5883 closed defect (bug) (worksforme)

bp_core_new_nav_item does not work with a hyphen in the slug

Reported by: zudie's profile zudie Owned by:
Milestone: Priority: normal
Severity: normal Version: 2.0.3
Component: Route Parser Keywords: reporter-feedback
Cc:

Description

Adding an extra page to the Profile menu. The following code works:

bp_core_new_nav_item(
	array(
				'name' => 'My Lot',
				'slug' => 'mylot',
				'parent_url' => $bp->loggedin_user->domain . $bp->members->slug . '/',
				'parent_slug' => $bp->members->slug,
				'default_subnav_slug' => 'mylot',
				'position' => 80,
				'show_for_displayed_user' => true,
				'screen_function' => 'im_my_lot_nav',
				'item_css_id' => 'mylot'			
	));

Now if I change the slug to 'my-lot' the page isn't found anymore and the Members List is displayed instead.

Change History (5)

#1 @DJPaul
10 years ago

  • Milestone changed from Awaiting Review to 2.2

Haven't tested but would like for us to fix this in 2.2 because I think most people would expect a hyphen to work in a slug field (they normally do).

#2 @DJPaul
10 years ago

  • Component changed from Members to Rewrite Rules

#3 @DJPaul
10 years ago

  • Keywords good-first-bug added

A more challenging ticket to work on, but a good one if you want to learn a little about how BP's routing works.

#4 @imath
10 years ago

  • Keywords reporter-feedback added; good-first-bug removed

Well, i think there's no bug.

First zudie, you are mixing arguments that are used in bp_core_new_subnav_item() within bp_core_new_nav_item() which is not a big deal as BuddyPress will keep the good ones :)

Then, i wasn't able to reproduce, everything works fine with an hyphen in the slug.

I've created this gist to illustrate how to use the two nav functions. You can use it to test eveything is ok.
https://gist.github.com/imath/2b8806431cc7a6f39f74

#5 @r-a-y
10 years ago

  • Milestone 2.2 deleted
  • Resolution set to worksforme
  • Status changed from new to closed

zudie - imath's examples should explain what is needed to allow hyphens to work on BP nav pages.

Going to close this one. Feel free to reopen if you are experiencing problems.

Note: See TracTickets for help on using tickets.