MyBB Community Forums

Full Version: Customize the breadcrumb list
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I tried to do this by editing the template but it will take more than that, I suspect.

I would like the breadcrumb to leave OUT the category link, so it would look like...

B-Board Title / (sub)Forum / Thread

I've taken a look at the functions.php file in the inc folder and I'm thinking that it might be somewhere within that file, but I don't know what to change to make this happen.

Can anyone here help me out?

Thanks.
Ok here's a start:

The function you want to modify is build_forum_breadcrumbs. Normally you pass in the current forum ID into this function, and it will build the breadcrumbs for all the parents by recursion. However, you want to modify this function (remove the recursion; just have it run once for the current forum) to just add the breadcrumb just for the current forum, then quit out.
Thanks for your answer DennisTT.

I looked through the functions.php and found a section that starts on line 2213 that is probably where I need to edit. I don't know what portion to edit out. Are you able to give me specifics?

Here is the section of code:
 * Build the breadcrumb navigation trail from the specified items
 *
 * @return The formatted breadcrumb navigation trail
 */
function build_breadcrumb()
{
	global $nav, $navbits, $templates, $theme, $lang;

	eval("\$navsep = \"".$templates->get("nav_sep")."\";");

	if(is_array($navbits))
	{
		reset($navbits);
		foreach($navbits as $key => $navbit)
		{
			if(isset($navbits[$key+1]))
			{
				if(isset($navbits[$key+2])) { $sep = $navsep; } else { $sep = ""; }
				eval("\$nav .= \"".$templates->get("nav_bit")."\";");
			}
		}
	}
	$navsize = count($navbits);
	$navbit = $navbits[$navsize-1];
	if($nav)
	{
		eval("\$activesep = \"".$templates->get("nav_sep_active")."\";");
	}
	eval("\$activebit = \"".$templates->get("nav_bit_active")."\";");
	eval("\$donenav = \"".$templates->get("nav")."\";");
	return $donenav;
}

/**
 * Add a breadcrumb menu item to the list.
 *
 * @param string The name of the item to add
 * @param string The URL of the item to add
 */
function add_breadcrumb($name, $url="")
{
	global $navbits;

	$navsize = count($navbits);
	$navbits[$navsize]['name'] = $name;
	$navbits[$navsize]['url'] = $url;
}

/**
 * Build the forum breadcrumb nagiation (the navigation to a specific forum including all parent forums)
 *
 * @param int The forum ID to build the navigation for
 * @param int 1 if we're in archive mode, 0 if not
 */
function build_forum_breadcrumb($fid, $archive=0)
{
	global $pforumcache, $db, $currentitem, $forum_cache, $navbits, $lang, $base_url, $archiveurl;

	if(!$pforumcache)
	{
		if(!is_array($forum_cache))
		{
			cache_forums();
		}
		foreach($forum_cache as $key => $val)
		{
			$pforumcache[$val['fid']][$val['pid']] = $val;
		}
	}
	if(is_array($pforumcache[$fid]))
	{
		foreach($pforumcache[$fid] as $key => $forumnav)
		{
			if($fid == $forumnav['fid'])
			{
				if($pforumcache[$forumnav['pid']])
				{
					build_forum_breadcrumb($forumnav['pid'], $archive);
				}
				$navsize = count($navbits);
				$navbits[$navsize]['name'] = $forumnav['name'];
				if($archive == 1)
				{
					// Set up link to forum in breadcrumb.
					if($pforumcache[$fid][$forumnav['pid']]['type'] == 'f' || $pforumcache[$fid][$forumnav['pid']]['type'] == 'c')
					{
						$navbits[$navsize]['url'] = "{$base_url}forum-".$forumnav['fid'].".html";
					}
					else
					{
						$navbits[$navsize]['url'] = $archiveurl."/index.php";
					}
				}
				else
				{
					$navbits[$navsize]['url'] = "forumdisplay.php?fid=".$forumnav['fid'];
				}
			}
		}
	}
	return 1;
}

/**
 * Resets the breadcrumb navigation to the first item, and clears the rest
 */
function reset_breadcrumb()
{
	global $navbits;

	$newnav[0]['name'] = $navbits[0]['name'];
	$newnav[0]['url'] = $navbits[0]['url'];
	unset($GLOBALS['navbits']);
	$GLOBALS['navbits'] = $newnav;
}

/**
Replace the existing build_forum_breadcrumbs function with this, see if it works:

function build_forum_breadcrumb($fid, $archive=0)
{
    global $pforumcache, $db, $currentitem, $forum_cache, $navbits, $lang, $base_url, $archiveurl;
if($archive)
{
    if(!$pforumcache)
    {
        if(!is_array($forum_cache))
        {
            cache_forums();
        }
        foreach($forum_cache as $key => $val)
        {
            $pforumcache[$val['fid']][$val['pid']] = $val;
        }
    }
    if(is_array($pforumcache[$fid]))
    {
        foreach($pforumcache[$fid] as $key => $forumnav)
        {
            if($fid == $forumnav['fid'])
            {
                if($pforumcache[$forumnav['pid']])
                {
                    build_forum_breadcrumb($forumnav['pid'], $archive);
                }
                $navsize = count($navbits);
                $navbits[$navsize]['name'] = $forumnav['name'];
                if($archive == 1)
                {
                    // Set up link to forum in breadcrumb.
                    if($pforumcache[$fid][$forumnav['pid']]['type'] == 'f' || $pforumcache[$fid][$forumnav['pid']]['type'] == 'c')
                    {
                        $navbits[$navsize]['url'] = "{$base_url}forum-".$forumnav['fid'].".html";
                    }
                    else
                    {
                        $navbits[$navsize]['url'] = $archiveurl."/index.php";
                    }
                }
                else
                {
                    $navbits[$navsize]['url'] = "forumdisplay.php?fid=".$forumnav['fid'];
                }
            }
        }
    }
}
else
{
        if(!is_array($forum_cache))
        {
            cache_forums();
        }
                $navsize = count($navbits);
                $navbits[$navsize]['name'] = $forum_cache[$fid]['name'];
                    $navbits[$navsize]['url'] = "forumdisplay.php?fid=".$fid;
}
    return 1;
}