As designed Unable to add a breadcrumb item that links to the current page

AddonsLab

Well-known member
Affected version
XenForo 2.x
Hello,

While working on a project we found out, that it is impossible to add a link in the breadcrumb that links to the current page. This is not something you used in any default XenForo pages, following the standard of having the breadcrumbs to the current page and the page name itself in xf:h1 tags. but in case of this project, this is a requirement as the page does not have a header text by design, so the name of the page should be included in the breadcrumbs.

The narrowed down the problem to the PAGE_CONTAINER template and "breadcrumbs" macro in it. The loop <xf:foreach loop="$breadcrumbs" value="$breadcrumb" if="$breadcrumb.href != $xf.uri"> explicitely skips any breadcrumb entries that point to the current page, so having xf:breadcrumb tag in the template is ignored.

The same project was working fine XenForo 2.0.x, and we found the cause to be some unrelated change in 'request.paths' container item, which would return a full URL with scheme and domain name in XenForo 2.0.12, and returns an absolute URL without the domain name since XenForo 2.1.x (did not verify the exact version where the change happened). As a result, the same conditional in breadcrumbs macro would not skip the relative URL and add it to the breadcrumbs.

A temporary workaround for XenForo 2.1.x is to add the breadcrumbs using URL full:prefix instead of just prefix and it will not match $xf.uri anymore.

Not really sure what would be the best to resolve the issue. Maybe this change should be removed from the template, and replaced with a check in PHP in a way that developers can see easier what's going on and why the breadcrumb is missing.

Please let me know if you need any further information from my side.

Thank you!
 
Since breadcrumbs are a trail of how you arrived on a page, there are two trains of thought...

1) The current page should not be in the breadcrumb list because you are already there (XenForo's default for so long as I can remember)
2) The current page should be in the breadcrumb list but it should not be clickable. (no sense in having a link to the page you're already on)

I agree with #1, but can understand #2. So, I'm not sure this is so much a bug in 2.1 as it is enforcement of the XF standard.
 
Last edited:
Snog is right - we did start enforcing this standard more heavily, though that was starting with XF 2.0. It wasn't totally consistent in XF 1.x and nothing was enforced so we just started enforcing it for XF 2.0. So, yeah, not sure where the idea that this is a recent change is coming from.

But, indeed, it is a deliberate step and no plans to change it right now. If you are trying to enforce a breadcrumb for the page you are on, it's possible you're going against the standards we have set, and you may want to reconsider that. Otherwise, you will just have to implement your own workaround.
 
Back
Top Bottom