Add caching by url.path to rigel_preprocess_breadcrumb()

Created on 8 September 2023, over 1 year ago

Problem/Motivation

  • The rigel_preprocess_breadcrumb() appends the page title to the end of the trail. In Drupal, breadcrumbs are cached based on the parent breadcrumb item.
  • So if the path is: Home / Parent 1 / Page title, the breadcrumb is cached from Home / Parent 1. Then if we go to another page that looks like Home / Parent 1 / Page title 2, since the caching happens at Parent 1, we'll see Home / Parent 1 / Page title instead of Home / Parent 1 / Page title 2
  • To get around this because we have Page title in the breadcrumb trail, we need to set the following $variables['#cache']['contexts'][] = 'url.path'; in rigel_preprocess_breadcrumb()
  • This changed happened in Drupal 8: https://www.drupal.org/node/2699627 β†’ . To make sure we don't blow up the cache too much, we should only set the cache context if the page isn't a 404.
πŸ› Bug report
Status

Fixed

Version

6.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States baldwinlouie

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

Comments & Activities

Production build 0.71.5 2024