0

I have created one custom page. Also created breadcrumb service which perfectly work for admin page but doesn't work for custom page.Even I have checked my custom theme setting where breadcrumb visibility is set true.

Snippet of code

company.services.yml
services:
  company.breadcrumb:
    class: Drupal\company\Breadcrumb\CompanyBreadcrumbBuilder
    tags:
      - { name: breadcrumb_builder, priority: 100 }


CompanyBreadcrumbBuilder.php

namespace Drupal\company\Breadcrumb;
use Drupal\Core\Breadcrumb\Breadcrumb;
use Drupal\Core\Breadcrumb\BreadcrumbBuilderInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Link;

class CompanyBreadcrumbBuilder implements BreadcrumbBuilderInterface{
    /**
        * {@inheritdoc}
        */
    public function applies(RouteMatchInterface $attributes) {
        $parameters = $attributes->getParameters()->all();

        return true;
    }

    /**
        * {@inheritdoc}
        */
    public function build(RouteMatchInterface $route_match) {
        $breadcrumb = new Breadcrumb();
        $breadcrumb->addLink(Link::createFromRoute('Home', '<front>'));
        $breadcrumb->addLink(Link::createFromRoute('Article', '<front>'));
        return $breadcrumb;
    }
}

m missing something like setting?

Note: I m using bootstrap as base theme.

3
  • 1
    You still have to ensure the block is being output in a region or you are injecting the breadcrumb as a twig variable.
    – Kevin
    Commented May 28, 2018 at 14:50
  • 1
    YEP what ^^^ Kevin said make sure you place the block !
    – taggartJ
    Commented May 30, 2018 at 0:31
  • Thanks. Breadcrumb block was disable under block list. Once it was enable it was working perfectly.
    – Sudha
    Commented May 30, 2018 at 5:35

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.