[buddypress-trac] [BuddyPress Trac] #6534: A new API to manage single items navigation

buddypress-trac noreply at wordpress.org
Thu Jun 25 16:56:52 UTC 2015


#6534: A new API to manage single items navigation
-------------------------+------------------------------------
 Reporter:  imath        |      Owner:
     Type:  enhancement  |     Status:  new
 Priority:  high         |  Milestone:  2.4
Component:  API          |    Version:
 Severity:  normal       |   Keywords:  has-patch dev-feedback
-------------------------+------------------------------------
 We've discussed about it yesterday during dev-chat, this is the navigation
 part i had previously included in the last patch i've attached to #6026.

 For the blogs single items, it's a kind of "blocker", so the soonest we
 have this in, the best it is, of course soon doesn't mean quick and dirty
 :)

 I've included a unit test so that's easier to understand the API. In it,
 i'm simulating a blogs single item, i build a nav for the admin and for a
 regular user and i remove the nav.

 ===== How i use it in #6026 =====

 Into `BP_Blogs_Component->setup_globals()`, i init the nav this way
 {{{
 $this->nav = new BP_Single_Item_Navigation( array(
         'component_id'     => $this->id,
         'component_slug'   => bp_get_blogs_root_slug(),
         'single_item_name' => 'blog',
 ) );
 }}}

 Then into `BP_Blogs_Component->setup_nav()`, once i'm sure it's a blogs
 single item we're viewing i build the nav and subnav items to finally
 populate the blogs single item navigation this way :
 {{{
 $this->nav->setup_nav( $item_main_nav, $item_sub_nav );
 }}}

 Then in `blogs/single/` templates i use these two template functions to
 display the nav and the subnav :
 - `bp_single_item_main_nav()` a wrapper for
 `BP_Single_Item_Navigation->display_main_nav()`
 - `bp_single_item_sub_nav()` a wrapper for
 `BP_Single_Item_Navigation->display_sub_nav()`

 ===== Outputing a single item nav thanks to an object ID =====
 That was r-a-y's suggestion in slack. IMHO, this is quite complicated. If
 we take the groups single item, the different elements of its navigation
 are built once the current group is set and about to be '''displayed''' (I
 actually do the same for blogs single items). So i think we should first
 make sure the API will behave correctly for our current way of setting
 single items nav. And work on this need for a future release.

 ===== Improvements to the API =====
 About the class, i think we should have specific methods or filters to
 control the access to a page attached to a nav or a subnav. So far i've
 mimicked how it was managed in `bp_nav` and `bp_option_nav` and adapted it
 to a single item (eg: blogs or groups, but that wouldn't match for a
 displayed user as the `bp_current_component()` is not the user).

 I'd love to have your feedbacks, (in particular @boonebgorges and @dcavins
 's ones)

--
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/6534>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac


More information about the buddypress-trac mailing list