Multiple contextual filters break expected breadcrumb structure

Created on 11 May 2023, about 1 year ago
Updated 16 October 2023, 9 months ago

Problem/Motivation

If you have a menu item linking to a contextual filter value on a view page display that has multiple contextual filters, the breadcrumb pattern adds an extra crumb to the breadcrumbs. For example, if you have a top level menu item that links to a view page display that has two contextual filters and the path in the menu links to "/myview/mytermname," the breadcrumbs for that menu item will add the view title as an extra crumb to your breadcrumbs. This looks like "Home -> My Menu Item Title -> My View Title" when I would expect the breadcrumb to look like "Home -> My Menu Item Title".

Steps to reproduce

  • Build a fresh Drupal site using the Standard profile so that your site has Basic Page and Tags already created
  • Install and enable menu_breadcrumb
  • Add a new Taxonomy to your site
  • Add two entity reference fields to Basic page: one for Tags and one for your new taxonomy
  • Create a node that use both Tags and your new taxonomy.
  • Create a new view. Make sure you create a page display for your new view
  • Add two relationships to your view page, both using the "Taxonomy terms on node" relationship. Configure one for tags and the other for your new taxonomy
  • Add two contextual filters to your view page, both using the "Taxonomy term: Name" filter. Configure one for the relationship you made with tags and the other for the relationship you made with your new taxonomy.
  • Get a path using the first level of contextual filter you just made. It should be something like /myview/mytermname. Add this path to the menu as a top level menu item
  • I would expect the menu item to look like "Home -> Menu Item Name." Instead, verify that your breadcrumbs look like "Home -> Menu Item Name -> View Title"

Proposed resolution

Ideally, this would be fixed so that only the menu paths and menu title are used in the breadcrumb. If that's not possible, maybe instead there could be a way to have a list of ignored paths for this module? I could have a fix to this bug by using easy_breadcrumb or another custom breadcrumb module, but menu_breadcrumb is overriding any customizations I make to my breadcrumbs.

πŸ› Bug report
Status

RTBC

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States angelamnr

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @angelamnr
  • Open on Drupal.org β†’
    Core: 9.5.x + Environment: PHP 8.0 & MySQL 5.7
    last update about 1 year ago
    Waiting for branch to pass
  • @angelamnr opened merge request.
  • πŸ‡ΊπŸ‡ΈUnited States angelamnr

    Did some debugging on this. I discovered that the route parameters in the conditional on line 409 in MenuBasedBreadcrumbBuilder.php were sorted slightly differently for some reason. If the array sorting is normalized before running the conditional, then it resolves to TRUE and the menu breadcrumb appears as expected on views pages using two or more contextual filters.

  • Status changed to Needs review about 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States angelamnr
  • Status changed to RTBC about 1 year ago
  • πŸ‡³πŸ‡ΏNew Zealand RoSk0 Wellington

    This patch does fix the issue for us on 8.x-1.16 and Drupal 9.5.

  • Open on Drupal.org β†’
    Core: 9.5.x + Environment: PHP 8.0 & MySQL 5.7
    last update about 1 year ago
    Waiting for branch to pass
  • πŸ‡³πŸ‡ΏNew Zealand RoSk0 Wellington

    Thanks Angela for reporting and fixing the bug!

    Capturing MR request state in the patch to be used with composer-patches.

  • Open on Drupal.org β†’
    Core: 9.5.x + Environment: PHP 8.0 & MySQL 5.7
    last update 10 months ago
    Waiting for branch to pass
  • πŸ‡¨πŸ‡³China randy Tang

    When the menu has external links, the following errors will occur
    UnexpectedValueException: External URLs do not have internal route parameters.

  • Open on Drupal.org β†’
    Core: 9.5.x + Environment: PHP 8.0 & MySQL 5.7
    last update 9 months ago
    Waiting for branch to pass
Production build 0.69.0 2024