• Hi there,
    I am using the latest version of the plugin, wordpress and buddypress. Is there a way to get the breadcrumbs to show correctly on buddypress pages?

    It shows part of it at the moment like:

    home -> groups (if on the groups page, which is correct)
    home -> newgroup (if on the newgroup page) – but here it should show:
    home -> groups -> newgroup

    same goes for members:

    home > members is correct
    home > sascha —- but that should be: home > members > sascha

    I looked at the code, but I cannot figure a way to get it to display properly. I do not even know why it shows the component (groups/members) correctly, but then does not show them when one level further.
    If I could get an example for one buddypress component, I would not mind trying to put the rest together for the other components myself.
    Thanks,
    Sascha

    https://wordpress.org/plugins/breadcrumb-navxt/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author John Havlik

    (@mtekk)

    I will look into this for 5.3.0, it may very well be caused by the same underlying issue described by https://github.com/mtekk/Breadcrumb-NavXT/issues/94

    In the end, if BuddyPress is doing something “non-standard” requiring BuddyPress specific code, then an extension plugin for Breadcrumb NavXT will be necessary.

    Thread Starter landwire

    (@landwire)

    Hi John,
    thanks for the quick reply. At the moment I am using an extension of Justin’s “Breadcrumb Trail” plugin to show the breadcrumbs, which works. Here is the code, in case it helps you with the buddypress side of things. Though I am not sure if it covers all eventualities.

    class buddypress_Breadcrumb_Trail extends Breadcrumb_Trail
    {
    
        /**
         * Runs through the various buddyPress conditional tags to check the current page being viewed.  Once
         * a condition is met, add items to the $items array.
         *
         * @since  0.6.0
         * @access public
         * @return void
         */
        public function do_trail_items()
        {
            global $bp;
            /* Add the network and site home links. */
            $this->do_network_home_link();
            $this->do_site_home_link();
    
            $trail_end = '';
    
            if ( !empty( $bp->displayed_user->fullname ) ) { // looking at a user or self
                $this->items[] ='<a href="' . bp_get_members_directory_permalink() . '">' . get_the_title( $bp->pages->members->id ) . '</a>';
                $this->items[] = '<a href="' . $bp->displayed_user->domain . '" title="' . strip_tags( $bp->displayed_user->userdata->display_name) . '">' . strip_tags( $bp->displayed_user->userdata->display_name ) .'</a>';
    
            } else if ( $bp->is_single_item ) { // we're on a single item page
                $this->items[] = '<a href="'. get_permalink( $bp->pages->{$bp->current_component}->id ) .'" title="'. esc_attr( strip_tags( get_the_title( $bp->pages->{$bp->current_component}->id ) ) ) .'">'. get_the_title( $bp->pages->{$bp->current_component}->id ) .'</a>';
                $this->items[] = '<a href="'. get_permalink() . '" title="' . esc_attr( $bp->bp_options_title ) . '">' . $bp->bp_options_title . '</a>';
    
            } else if ( $bp->is_directory ) { // this is a top level directory page
                $trail_end = get_the_title( $bp->pages->{$bp->current_component}->id );
            } else if ( bp_is_register_page() ) {
                $trail_end = __( 'Create an Account', 'buddypress' );
            } else if ( bp_is_activation_page() ) {
                $trail_end = __( 'Activate your Account', 'buddypress' );
            } else if ( bp_is_group_create() ) {
                $this->items[] = '<a href="' . get_permalink( $bp->pages->groups->id ) . '" title="' . esc_attr( get_the_title( $bp->pages->groups->id ) ) . '">' . get_the_title( $bp->pages->groups->id ) . '</a>';
    
                $trail_end = __( 'Create a Group', 'buddypress' );
    
            } else if ( bp_is_create_blog() ) {
                $this->items[] = '<a href="'.  home_url().'/'. $bp->current_component .'" title="'. ucwords($bp->current_component) .'">'. ucwords($bp->current_component) .'</a>';
                $trail_end = __( 'Create a Blog', 'buddypress' );
            }
            if ($trail_end) {
                $this->items[] = $trail_end;
            }
    
            /* Return the BuddyPress breadcrumb trail items. */
            $this->items = apply_filters('breadcrumb_trail_get_buddypress_items', $this->items, $this->args);
        }
    }

    Thanks for the Breadcrumb Trail code here Iandwire! Very handy. Just what I’ve been looking for.

    I’ve been scouring the Breadcrumb Trail support pages for a solution to enable that plugin to accurately represent BuddyPress pages. Seems odd that they don’t. I’ve used your code, and have had success on those BP pages which use the stock standard URI structure (register etc.) i.e. which are ‘off the root’.

    However, I’ve located the majority of my BuddyPress pages under a different path. And this is where I come unstuck.

    Rather than groups (et al) being under the standard issue: domain.ext/groups/… 
    I’ve got them like so: domain.ext/our-community/groups… 

    Am I correct in thinking your code is expecting the BP components to be in their initial/default location? And if so, I don’t suppose you’d point me in the direction of how to solve this particular issue? Is there a way of manipulating the code to ‘work backwards’; to identify the current BP component/s from the end of the URI and ignore any non-standard path/segments at the beginning. I’m thinking I may want to use more that one initial URI segment in the future…

    VERY much appreciated!
    Dave

    P.S. Apologies John for talking about another plug! The snippet Iandwire supplied here is not one that I was able to find in the official Breadcrumb Trail support forum.

    Actually, now I look at it all again, I can see that some of the pages (such as register, and the groups main list view) do in fact work well when I introduce a first level path to the URI I run into the problem of the breadcrumbs not working on anything to do with /members/… and /groups/…

    I’ll keep investigating and keep my results posted—here?

    Thanks.

    I’m very surprised that buddypress, a part of WordPress, still doesn’t do proper breadcrumbs. Click groups, you get:

    Home > Groups

    Great. Click inside a group, and that all goes away and you just get “Home”. There are other anomalies but this one is the most glaring. Go to buddypress.org and use the support forums. Click into a forum and the sidebar nav for the forums listings goes away and there is no breadcrumb. I found it rather glaring.

    Plugin Author John Havlik

    (@mtekk)

    I’m very surprised that buddypress, a part of WordPress, still doesn’t do proper breadcrumbs.

    BuddyPress is very much not part of WordPress core, it is a WordPress plugin like bbPress and Breadcrumb NavXT. Like bbPress, to do what it needs to do, BuddyPress has to extend beyond WordPress’ API, which Breadcrumb NavXT does not pick up on without help. Extra functionality is provided through extension plugins to Breadcrumb NavXT. Breadcrumb NavXT has an extension plugin to help with bbPress support and an extension plugin to help with BuddyPress support is in the works.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘BuddyPress and Breadcrumbs’ is closed to new replies.