XF 2.1 Rebuild breadcrumbs?

asprin

Active member
As part of my add-on, I've seen that when I go the landing page (my addon controller->index function), the breadcrumb getting generated is as follows:
1582374701012.png

The "FC" links to localhost/xen/fc where "xen" is the root folder and "fc" is my add-on public controller.

Is there a way to prepend the breadcrumb with the forum index link (localhost/xen)? Something like this:
1582374856458.png



The things I've tried so far after looking at existing templates:
(1) Using source attribute on the breadcrumb tag
HTML:
<xf:title>Some titles goes here</xf:title>
<xf:breadcrumb source="$crumbs" />

<!--
$crumbs would be something like this:
array(
    ['href' => 'aaa', 'value' => 'Forums'],
    ['href' => 'bbb', 'value' => 'FC']
)
-->
This results in the following (the root link isn't getting overwritten):
1582375124876.png


(2) Using breadcrumbs tag
HTML:
<xf:title>Some title</xf:title>
<xf:breadcrumb href="aaa">Forums</xf:breadcrumb>
<xf:breadcrumb href="bbb">FC</xf:breadcrumb>
This results in the following (same result as (1)):
1582375318817.png


In summary, I'm able to append to the existing breadcrumb but not prepend or remove the root link. How would I go about building the breadcrumb from scratch via PHP or within a template if at all it is possible?
 
On a sidenote, this isn't working (i.e. AAA doesn't get appended to the existing crumb)

HTML:
<xf:breadcrumb href="{{link('fc/view', $event)}}">AAA</xf:breadcrumb>

whereas using a hardcoded value works (i.e. I do get to see AAA at the end)
HTML:
<xf:breadcrumb href="fc/fiew">AAA</xf:breadcrumb>

but then I would lose the route format data. Any way to have link supported here?
 
link() should work inside href here - because that does work in core templates too. Don't know what's going on here.. 🤔
 
link() should work inside href here - because that does work in core templates too. Don't know what's going on here.. 🤔
The thing is, without the second argument, the breadcrumb appears on the page. But as soon as I add the entity object, it disappears from the page.

This works:
Code:
<xf:breadcrumb href="{{link('fc/view')}}">AAA</xf:breadcrumb>

But this doesn't
Code:
<xf:breadcrumb href="{{link('fc/view', $event)}}">AAA</xf:breadcrumb>

And $event is defined and valid as I'm using it below in the template later.
 
Did a little debugging and found this out

Code:
<xf:set var="$test">{{ link('fc/view', $event) }}</xf:set>

Result: /xen/index.php?fc/view/some-title.12
The above proves the route is defined and working fine, right?

And without the entity object:
Code:
<xf:set var="$test">{{ link('fc/view') }}</xf:set>

Result: /xen/index.php?fc/view/


And are you using any link building callback?
No, I'm not as far as I know.
 
Back
Top Bottom