Skip to main content
Drupal 8

Main navigation

  • Home
    • Question And Answer
    • NEWS
    • Projects
  • Tutorials - Drupal
    • Android
    • Other
User account menu
  • Log in

Breadcrumb

  1. Home

Drupal 8 breadcrumb functions (menu_get_active_trail, and menu_link_get_preferred ...)

By editor , 26 September, 2016
Question

How to breadcrumb functions in drupal 8 ?
menu_get_active_trail(), menu_set_active_trail(), and menu_link_get_preferred()
menu_get_active_breadcrumb () ....

Those functions [ menu_set_active_item(), menu_set_active_trail(), menu_get_active_trail(), menu_link_get_preferred() ] are removed on D8 and replaces with drupal 8 service. You can use following example to get data and to edit.

Example :

$menu_name = NULL;
$active_trail = \Drupal::service('menu.active_trail');
//To get item ids
$ids = $active_trail->getActiveTrailIds($menu_name);
//To get links
$link = $active_trail->getActiveLink($menu_name);

//To get menu name
$menu_name = $link->getMenuName();

Tags

  • Drupal 8
  • Code
Create and translate menu links in Drupal 8
Make a Link list and Submenu
Drupal 8 Menu System

Comments

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.

Links

  • Drupal.org
  • Drupal core release cycle
  • Drupal events with ease
  • Unit test with Drupal using PHPUnit (Drupal 10)
  • Tokens for file upload url
  • Tips for Docker
  • CKEditor inline image files usage for custom forms.
  • Install Docker on Linux Mint
  • Install PHP 8.1
  • Drupal Security Best Practices
  • Order and sort items with tabledrag
  • Add a custom service YAML container
  • Apply a patch with composer