Skip to content

Directory Navs

imath edited this page Jun 16, 2016 · 3 revisions

BP Nouveau is using a generic template to output the components directory navs. It is located in common/nav/directory-nav.php. BP Nouveau is also using the BP_Core_Nav API to store the directory nav items of each component. There's now a specific loop inside the common/nav/directory-nav.php template that is using this new way of managing directory navs.

It's still possible to override the common/nav/directory-nav.php and edit the markup to fit a specific theme.

It's still possible to add nav items but we're not using anymore the Legacy hooks. If WP_DEBUG mode is on and a legacy hook is used, then a feedback notice will be output into the footer to inform about the filter to use instead.

To add a nav item to the members directory, people can do the following:

function my_custom_members_directory_nav_item( $nav_items = array() ) {
   /**
    * The position argument for All members is 5
    * The position argument for Personal is 15
    * - so to put a nav between these we can use the 10 value,
    * - to put a nav before the All members, we can use the 0 value,
    * - to put a nav after personal we can use the 25 value.
    */
   $position = 25;

   $nav_items['custom'] = array(
     'component' => 'members',
     'slug'      => 'custom',  // slug is used because BP_Core_Nav requires it, but it's the scope used by AJAX
     'li_class'  => array(),   // If you need to include some specific classes to the li element.
     'link'      => '',        // the link to reach your specific directory page, or to use as a fallback to AJAX
     'title'     => '',        // The title attribute of the link
     'text'      => '',        // The text to output for the link
     'count'     => 0,         // The count span to use, set it to false to not include this span. 
     'position'  => $position, // The position of the nav
   );

   return $nav_items;
}
add_filter( 'bp_nouveau_get_members_directory_nav_items', 'my_custom_members_directory_nav_item' );

You can read about the history of this new way of managing the directory navs in #16