For example, in a "blog post" page I'd like the breadcrumb to display like this:
I'm controlling all breadcrumbs from a single place, a class that implements BreadcrumbBuilderInterface
. Its build
method looks like this:
public function build(RouteMatchInterface $route_match) {
$b = new Breadcrumb();
$node = $route_match->getParameter('node');
if ($node && $node->getType() == 'blog_post') {
$b->addLink(Link::createFromRoute($this->t('Blog'), 'blog.home'));
$b->addLink(Link::createFromRoute($this->t('Recipes'), 'blog.recipes_landing'));
//I want this next item to not be a link, and to show "Recipe" and not the node title.
//$b->addLink(Link::createFromRoute($this->t('Recipe'), 'nothing!'));
}
return $b;
}
How can I make this happen? I saw somewhere (not sure where, in a code comment perhaps) that this last item is supposed to be added in the theme layer, but I don't want to split my logic, especially since I don't just want all breadcrumbs to show the page title as the last item (instead, for example, I want it to say "Recipe" if the content type is blog_post
).
Breadbrumb
class (the default works with typed links only), a customBeadcrumbBuilder
service (the default only works with the defaultBreadcrumb
class), your own theme function (Thelinks
theme won't work for this, especially if you're interested in getting decent markup produced), a custom block for the new breadcrumb, etc. Hope I'm wrong but I don't see an easier way