MyBB Community Forums

Full Version: Breadcrumb Fix
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

Breadcrumbs are a bit of a sticking point for me with mybb.

I am customizing my website so that I have a custom index.php page and my old index.php is renamed forum.php.

With the breadcrumbs - it's still showing the forum.php as the first link.


Is there a way to correct this? I'd like to show the first breadcrumb link as the new home.php page and any link after that should show AFTER that link.
In your forum install directory, backup global.php and then edit it.

Circa line 968, find:
// Add our main parts to the navigation
$navbits = array();
$navbits[0]['name'] = $mybb->settings['bbname_orig'];
$navbits[0]['url'] = $mybb->settings['bburl'].'/forum.php';

Change it to:
// Add our main parts to the navigation
$navbits = array();
$navbits[0]['name'] = $mybb->settings['bbname_orig'];
$navbits[0]['url'] = 'your_custom_index_location_and_filename.php';
(2019-02-21, 01:52 PM)Ersatz Haderach Wrote: [ -> ]In your forum install directory, backup global.php and then edit it.

Circa line 968, find:
// Add our main parts to the navigation
$navbits = array();
$navbits[0]['name'] = $mybb->settings['bbname_orig'];
$navbits[0]['url'] = $mybb->settings['bburl'].'/forum.php';

Change it to:
// Add our main parts to the navigation
$navbits = array();
$navbits[0]['name'] = $mybb->settings['bbname_orig'];
$navbits[0]['url'] = 'your_custom_index_location_and_filename.php';

Thanks for the reply. I have done this prior and it works as intended.

What I was talking about is the first breadcrumb is always pointing to "forum" but the link is to the home.php page.

Prior to my changes, the first breadcrumb link would "Forum" ->Category A -> Forum A

So when a user sees it, it would be correct because the TOP page by default is the forum.

I've changed that top page to home.php and I would like the breadcrumb to reflect that.

[attachment=41563]

So, I came up with sort of a "hack" fix to this

What I did was add a css to hide the nth-child(2) in the breadcrumb

I then opened my forum.php page and added :
add_breadcrumb("Title here", "somename.php"); 

So it will display properly now with this "hack"

It still won't show "Forum" in the breadcrumb when someone is inside of a forum. So this is kind of a temp fix until I can figure out how to get it to display properly
I was going to suggest editing the nav (Templates > Navigation Templates > Nav) template.

It has:
{$nav}{$activesep}{$activebit}

$nav is pulled from global, so all you have to do is add a link in front of that and make global whatever you want. Or add a link behind it. I'm kind of lost on what's custom and where it goes, but that would be the way to do it.

<your_html_link>{$sep}{$nav}{$activesep}{$activebit}
or
{$nav}{$sep}<your_html_link>{$activesep}{$activebit}
or
<your_html_link>{$activesep}{$activebit}  <-- you mentioned hiding an nth child, this throws out global completely.
(2019-02-21, 04:40 PM)Ersatz Haderach Wrote: [ -> ]I was going to suggest editing the nav (Templates > Navigation Templates > Nav) template.

It has:
{$nav}{$activesep}{$activebit}

$nav is pulled from global, so all you have to do is add a link in front of that and make global whatever you want. Or add a link behind it. I'm kind of lost on what's custom and where it goes, but that would be the way to do it.

<your_html_link>{$sep}{$nav}{$activesep}{$activebit}
or
{$nav}{$sep}<your_html_link>{$activesep}{$activebit}
or
<your_html_link>{$activesep}{$activebit}  <-- you mentioned hiding an nth child, this throws out global completely.

I was thinking about this as well.

So basically, the index.php file I have renamed to forum.php and added .htaccess line to make home.php the new index.php

So the breadcrumb trail should look like this:
Home(home.php) - > Forum (forum.php) - > Category A - > Forum A

This is what it is displaying when I go to the home.php page

[attachment=41564]
I'll confess I'm lost as to what you're trying to do that editing global or inserting a custom link in the nav template won't accomplish. If it's because you've changed two pages and the second one isn't being counted as being in the hierarchy, maybe:

// Add our main parts to the navigation
$navbits = array();
$navbits[0]['name'] = "Your Home Page name";
$navbits[0]['url'] = 'your_custom_index_location_and_filename.php';
$navbits[1]['name'] = "Your Forum Name";
$navbits[1]['url'] = 'your_custom_forum_location_and_filename.php';

Skip the nav template and embed both in global ??
Right, I basically want to tell mybb to make my new home.php the first breadcrumb in the list vs the forum (index.php) page..

Ok,

I think I got it fixed

I basically changed this code to reflect the actual new homepage (home.php)

// Add our main parts to the navigation
$navbits = array();
$navbits[0]['name'] = $mybb->settings['bbname_orig'];
$navbits[0]['url'] = $mybb->settings['bburl'].'/forum.php';


I then added this code to the new forum page (forum.php), forumdisplay.php, and showthread.php

add_breadcrumb("Forum", "/forum"); 

This is the end result when in a forum


[attachment=41565]