Add more to the breadcrumb

Neil E.

Active member
I need to add one more step to the breadcrumb trail. What needs to be done?

Forums, click on any Node Title, breadcrumb shows Category Title.
I want Category Title plus Node Title at this point.

standard navigation code
<xen:navigation>
<xen:breadcrumb source="$nodeBreadCrumbs" />
</xen:navigation>

current modified navigation code (Node Title only shows up when viewing a thread)
<xen:navigation>
<xen:breadcrumb source="$nodeBreadCrumbs" />
<xen:breadcrumb href="{xen:link full:threads, $thread}">{$thread.title}</xen:breadcrumb>
</xen:navigation>

The purpose is to show the node title sooner in the breadcrumb since I am not using a header title when viewing the thread list. Desired result:

Viewing forum list, Breadcrumb = Forums, click on node
Viewing thread list, Breadcrumb = Forums, Category Title, Node Title, click on topic title
Viewing thread, Breadcrumb = Forums, Category Title, Node Title, Topic Title
 
I have spent a lot of time with the breadcrumbs from developing the Nodes As Tabs addon. You need to modify the controller:

library/XenForo/ControllerPublic/Forum.php

In the actionIndex() function, remove the red code. That is a boolean to "include self" in the node crumbs. It defaults to true:

Rich (BB code):
		$viewParams = array(
			'nodeList' => $this->_getNodeModel()->getNodeDataForListDisplay($forum, 0),
			'forum' => $forum,
			'nodeBreadCrumbs' => $ftpHelper->getNodeBreadCrumbs($forum, false),

			'canPostThread' => $forumModel->canPostThreadInForum($forum),
			'canSearch' => $visitor->canSearch(),

			'inlineModOptions' => $inlineModOptions,
			'threads' => $threads,
			'stickyThreads' => $stickyThreads,

			'ignoredNames' => $this->_getIgnoredContentUserNames($threads) + $this->_getIgnoredContentUserNames($stickyThreads),

			'order' => $order,
			'orderDirection' => $orderDirection,
			'orderParams' => $orderParams,
			'displayConditions' => $displayConditions,

			'pageNavParams' => $pageNavParams,
			'page' => $page,
			'threadStartOffset' => ($page - 1) * $threadsPerPage + 1,
			'threadEndOffset' => ($page - 1) * $threadsPerPage + count($threads) ,
			'threadsPerPage' => $threadsPerPage,
			'totalThreads' => $totalThreads,

			'showPostedNotice' => $this->_input->filterSingle('posted', XenForo_Input::UINT)
		);

		return $this->responseView('XenForo_ViewPublic_Forum_View', 'forum_view', $viewParams);

This can be made into an addon instead of a file edit if you want.
 
Thanks, Jake.

It's perfect.

I notice that your code change matches the section 'thread' (which did have the complete breadcrumb).

Code:
        $viewParams = array(
            'thread' => array(
                'discussion_open' => 1,
                'prefix_id' => $forum['default_prefix_id'],
            ),
            'forum' => $forum,
            'nodeBreadCrumbs' => $ftpHelper->getNodeBreadCrumbs($forum),
 
            'prefixes' => $this->_getPrefixModel()->getUsablePrefixesInForums($forumId),
 
            'attachmentParams' => $attachmentParams,
 
            'watchState' => $this->_getThreadWatchModel()->getThreadWatchStateForVisitor(false),
 
            'captcha' => XenForo_Captcha_Abstract::createDefault(),
 
            'pollExtraArray' => $pollExtraArray,
 
            'canLockUnlockThread' => $this->_getForumModel()->canLockUnlockThreadInForum($forum),
            'canStickUnstickThread' => $this->_getForumModel()->canStickUnstickThreadInForum($forum),
 
            'attachmentConstraints' => $this->getModelFromCache('XenForo_Model_Attachment')->getAttachmentConstraints(),
        );
        return $this->responseView('XenForo_ViewPublic_Thread_Create', 'thread_create', $viewParams);

I'm so glad that you are able to help with XF.
Would an addon be better for upgrading so the file is not overwritten?
 
The full breadcrumb is very handy. There are a few other places where I'd like to have the same functionality:

A) When viewing Forums sub-tabs (Watched Threads, What's New)
B) When viewing Members sub-tabs (Registered Members, Current Visitors, Recent Activity)
C) When viewing Conversations (show Conversation Title)
D) When viewing Account Pages (show page name)

Can any of these be added to the breadcrumb?
 
The full breadcrumb is very handy. There are a few other places where I'd like to have the same functionality:

A) When viewing Forums sub-tabs (Watched Threads, What's New)
B) When viewing Members sub-tabs (Registered Members, Current Visitors, Recent Activity)
C) When viewing Conversations (show Conversation Title)
D) When viewing Account Pages (show page name)

Can any of these be added to the breadcrumb?

Those aren't nodes so it's different. You would start by identifying the content template:

http://xenforo.com/community/threads/1-0-0-b1-how-to-identify-the-root-template-of-a-page.5591/

Then edit that template in your Admin CP. You need to add (or modify if it already exists) the xen:navigation block to define the breadcrumbs. Here is a code example from member_view:

Code:
<xen:navigation>
	<xen:breadcrumb href="{xen:link full:members, $user}">{$user.username}</xen:breadcrumb>
</xen:navigation>
 
I managed to spend some time on this and was able to add to the breadcrumb. The problem is that the last link does not function properly, it just goes back to the forum index. Here is what was added to the watch_threads template.

<xen:navigation>
<xen:breadcrumb><span class="crust><a class="crumb" itemprop="url" rel="up" href="http://www.odsc.on.ca/.xenforo/index.php?watched/threads"</a></span>
<span itemprop="title">Watched Threads</span><span class="arrow"><span>&gt;</span></span>
</xen:breadcrumb>
</xen:navigation>

Results in
xenforo70.webp

When inspected using Firebug
xenforo71.webp

In the last span class that is opened up a=" " so this looks to be the problem, but I don't know how to correct it.

www.odsc.on.ca/.xenforo/index.php
user "A"
pass "a1234"
 
You are doing it wrong. See the code example in my previous post. xen:breadcrumb has a href attribute for the hyperlink. And the content of xen:breadcrumb (between the two tags) is the text of the crumb.
 
As usual Jake is correct. I had a space in my first template edit that messed things up. Then I went on a convoluted tangent with alternate breadcrumb syntax trying to make things work. A fresh look at it and all I needed was the following:
<xen:navigation>
<xen:breadcrumb href="index.php?watched/threads">Watched Threads</xen:breadcrumb>
</xen:navigation>

So that has cleared up a few breadcrumb issues, however one instance has me baffled.
I added the following to find_new_threads to add Recent Threads to the breadcrumb and it worked fine.
<xen:navigation>
<xen:breadcrumb href="index.php?find-new/threads&recent=1">Recent Threads</xen:breadcrumb>
</xen:navigation>

Then I wanted to add What's New to the breadcrumb when looking at What's New. The problem is that What's New also uses the
find_new_threads template as per this post http://xenforo.com/community/threads/whats-new-template.36639/
Before setting up Recent Threads, I tried to get the breadcrumb working with What's New by itself. No luck with this at all.

So how do I get What's New working and then control two different sets of breadcrumb content in one template?
 
If it uses the same template there isn't much you can do. It's possible with an addon of course. You could define a breadcrumb variable in each controller and then use that as the source. Code example from thread_view:

Code:
<xen:navigation>
	<xen:breadcrumb source="$nodeBreadCrumbs" />
</xen:navigation>

Or you could specify two different content templates in the controllers.
 
Thanks Jake. I was hoping a conditional might be possible in find_new_threads, something like IF Recent Threads use this path, ELSE use this path (for What's New).
 
I have spent a lot of time with the breadcrumbs from developing the Nodes As Tabs addon. You need to modify the controller:

library/XenForo/ControllerPublic/Forum.php

In the actionIndex() function, remove the red code. That is a boolean to "include self" in the node crumbs. It defaults to true:

Rich (BB code):
        $viewParams = array(
            'nodeList' => $this->_getNodeModel()->getNodeDataForListDisplay($forum, 0),
            'forum' => $forum,
            'nodeBreadCrumbs' => $ftpHelper->getNodeBreadCrumbs($forum, false),

            'canPostThread' => $forumModel->canPostThreadInForum($forum),
            'canSearch' => $visitor->canSearch(),

            'inlineModOptions' => $inlineModOptions,
            'threads' => $threads,
            'stickyThreads' => $stickyThreads,

            'ignoredNames' => $this->_getIgnoredContentUserNames($threads) + $this->_getIgnoredContentUserNames($stickyThreads),

            'order' => $order,
            'orderDirection' => $orderDirection,
            'orderParams' => $orderParams,
            'displayConditions' => $displayConditions,

            'pageNavParams' => $pageNavParams,
            'page' => $page,
            'threadStartOffset' => ($page - 1) * $threadsPerPage + 1,
            'threadEndOffset' => ($page - 1) * $threadsPerPage + count($threads) ,
            'threadsPerPage' => $threadsPerPage,
            'totalThreads' => $totalThreads,

            'showPostedNotice' => $this->_input->filterSingle('posted', XenForo_Input::UINT)
        );

        return $this->responseView('XenForo_ViewPublic_Forum_View', 'forum_view', $viewParams);

This can be made into an addon instead of a file edit if you want.

I'm just researching this topic now.
This is exactly how I've done it, to include the thread title etc in the breadcrumb, as I too am not using the title part in the thread display.

Just a quick point. I know I've already done this now, successfully, but your post says "Remove the word false, etc etc, It defaults to true"
Don't you mean "Remove the word false, so then it will default to true". Just didn't sound right, reading it.

Anyway...that aside, is there anyway to include the current prefix in this instead of just the thread title.
 
I'm just researching this topic now.
This is exactly how I've done it, to include the thread title etc in the breadcrumb, as I too am not using the title part in the thread display.

Just a quick point. I know I've already done this now, successfully, but your post says "Remove the word false, etc etc, It defaults to true"
Don't you mean "Remove the word false, so then it will default to true". Just didn't sound right, reading it.

Anyway...that aside, is there anyway to include the current prefix in this instead of just the thread title.

That code change relates to node breadcrumbs. The thread title is not a node. Additional breadcrumbs such as thread titles are normally defined in the content template:

http://xenforo.com/community/threads/1-0-0-b1-how-to-identify-the-root-template-of-a-page.5591/

See this template for a code example:

Admin CP -> Appearance -> Templates -> member_view

Code:
<xen:navigation>
	<xen:breadcrumb href="{xen:link full:members, $user}">{$user.username}</xen:breadcrumb>
</xen:navigation>
 
Excellent, thanks Jake.

I've managed to edit the thread_view template, changing the navigation to the following

Code:
<xen:navigation>
   <xen:breadcrumb source="$nodeBreadCrumbs" />
   <xen:breadcrumb href="{xen:link full:threads, $thread}">{xen:helper threadPrefix, $thread, html, ''}&nbsp;{$thread.title}</xen:breadcrumb>
</xen:navigation>

This works fine. The prefix is there before the title.
I tried to put a conditional in the middle of it to only show if the prefix existed but it didn't like that.
However, how do I style the actual prefix part? Is it possible?
 
Top Bottom