When I define my own breadcrumb class/ module the first link always gets removed because of the preprocess function:

$show_breadcrumb_home = $this->theme->getSetting('breadcrumb_home');
    if (!$show_breadcrumb_home) {
      array_shift($breadcrumb);
    }

But it does not even check if the first item is the home page.

Is this by design?

Comments

sic created an issue. See original summary.

markhalliwell’s picture

Title: Preprocess class assumes the first item can always be removed if theme setting "breadcrumb_home" is false » Check if the first breadcrumb's path is actually <front> before removing it
Category: Bug report » Feature request

Technically, yes... this is by design.

I define my own breadcrumb class/ module

This is meant to work with core out-of-the-box and core adds the home link.

--

The only "solution" I could possible see is to check if the first link is actually the home path, however I'm not entirely sure if that's feasible. I know in 7.x they're already rendered links at this preprocess point. I honestly cannot, for the life of me, remember if this is true of 8.x as well. If they're not, this would be far easier to check here.

  • markcarver committed a3fe331 on 8.x-3.x
    Issue #2738571 by sic, markcarver: Check if the first breadcrumb's path...
markhalliwell’s picture

Category: Feature request » Bug report
Status: Active » Fixed
markhalliwell’s picture

StatusFileSize
new2.19 KB

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

digitalfrontiersmedia’s picture

This was never backported for 7.x-3.x yet the same problem can occur there.

markhalliwell’s picture

Because of what I said in #2:

I know in 7.x they're already rendered links at this preprocess point.

Implementing a fix for 7.x would require a lot more work and likely wouldn't be very efficient, performance wise.

I'd recommend just leaving the setting enabled so it doesn't remove it and then let another contrib module or your own custom code handle this.