Opened 12 years ago
Last modified 10 years ago
#2204 new defect (bug)
bbpress OR wp_nav_menu fails to set current_page_parent for forum-index page and children hirarchy
Reported by: | Mitesh Patel | Owned by: | johnjamesjacoby |
---|---|---|---|
Milestone: | 2.7 | Priority: | normal |
Severity: | normal | Version: | 2.2.3 |
Component: | General | Keywords: | needs-testing |
Cc: | stephen@…, alex@… |
Description
I am reporting this issue, as it seems a very many people are facing the issue, and although a ticket was generated in the past (I can't find it now) for the same topic 1-2 years back, It wasn't considered worth the effort then because the priorities were obviously on core functionalities. I guess now things are different.
I came across this problem in multiple current installation of wp 3.5, bp 1.6.4 and bbp 2.2, but the issue isn't version specific (as it was there 1-2 years back as well.)
The problem is essentially this. When a bbpress is installed (with or without buddypress). the user needs to create a page called forum to show the forums link in navigation menu, and to make the forum listing available to the users/subscribers. There are multiple ways to do this, including one way that does not create any new page but refers to the forums by adding a custom link in the menu referring to www.example.com/forum_base-slug (by default forums). In any of these ways, the forums functionality works fine, but the 'forums' menu item (in wp_nav_manu) doesn't get proper classes, that may highlight/differentiate that menu-item as current/active. The problem is encountered mostly, when the 'forums' link (even by any other name, say discussions) is a sub-item or a menu item like community > Forums. All the buddypress components work perfectly fine, highlighting the 'community' menu item, if the user is viewing any sub-item or sub-sub-sub item, so the problem is bbpress specific.
Inspecting the page source reveals that the current_page_parent class is attributed to some other page, however, that page is also not highlighted, as it seems it needs more than one classes to be attributed.
Further, the 'forums' menu is not highlighted when child items like an individual forum or topics are visited by the users current_page_ancestor also not attributed in such cases. this is the case with testbp.org, where "discussions" menu item is current/active only when you are viewing the forum index. any deeper, the highlight is lost.
Also, the problem is not there with 'support' menu item of buddypress.org or bbpress.org, where the 'support' menu item remains highlighted, irrespective of which forum page/topic the user is on. This is the correct behavior, which is broaken/needs repair in current version(s).
Attachments (1)
Change History (10)
#2
@
12 years ago
- Milestone changed from Awaiting Review to 2.4
Valid. Moving to 2.4 to address there. Anyone looking to help with this should check out the 'wp_nav_menu_objects' filter. If that doesn't work, a core patch will be needed in _wp_menu_item_classes_by_context() to let us add our own classes to menu items.
#3
@
12 years ago
I'm not programmer or designer, but a simple solution to this can be done by css the following way.
On each bbPress related page, the bbPress adds a class 'bbPress' to the body html element, so adding something like below would solve the problem in a non-obtrusive way.
body.bbPress #nav > li.menu-item-318 > a {
formatting for the highlighted menu item class
}
Where, menu-item-318 is the id of the page which should have been highlighted by the current_page_parent or current_menu_item class, which are not attached (for which this ticket is for).
Of course, this is just a hack, but it does get the work done.
#5
@
11 years ago
- Milestone changed from 2.5 to 2.6
2.5 is going to focus on performance improvements. Moving to 2.6.
#7
@
10 years ago
- Cc alex@… added
2204.diff is a first pass at attempting to fix this problem. I don't think it's complete though. One thing that needs to be decided is if every menu_item that has the forum_root_slug in it should be "activated" when on a bbPress page or if we should be more restrictive and only "activate" the menu_item if it's url is only the forum_root_slug or the site_url+forum_root_slug.
And there's probably other cases as well that I haven't thought of, but I'd be happy to develop this patch further. :)
As discussed on bbpress.org