When Panels everywhere is active, and the breadcrumb is printed in the site template provided by panels everywhere, tokens are not working.

I tested this by creating a panels everywhere panel which prints the page breadcrumb

then I created a panel for a term view page, and altered the breadcrumb overthere.

Problem seems to be panels breadcrumb triggers multiple times, and last time is the panels everywhere page, which tries to render the breadcrumb with the configuration provided in the term view panel, but has not the needed context to render the correct breadcrumb.

Comments

strykaizer’s picture

Issue summary: View changes

extra info added

hydra’s picture

I can confirm this bug. Unfortunally I havend found a good solution for it yet :(

A possible workaround for this, till this is fixed, is to don't use panels_breadcrumbs_build_breadcrumb for getting the breadrumb but directly call drupal_get_breadcrumb, since panels_breadcrumbs_build_breadcrumb is calling drupal_set_breadcrumb.

For easy use just replace panels_breadcrumbs_page_breadcrumb_content_type_render with the code below.

panels_breadcrumb.module line 250

<?php
/**
 * Render callback override of 'page_breadcrumb' ctools content-type.
 */
function panels_breadcrumbs_page_breadcrumb_content_type_render($subtype, $conf, $panel_args, $contexts) {
  $panelizer_conf = panels_breadcrumbs_get_panelizer_breadcrumb_conf();
  $current_page = page_manager_get_current_page();

  // Find which breadcrumb configuration to use.
  if (isset($conf['panels_breadcrumbs_state']) && $conf['panels_breadcrumbs_state']) {
    $correct_conf = $conf;
  }
  elseif (!empty($panelizer_conf)) {
    $correct_conf = $panelizer_conf;
  }
  elseif (!empty($current_page)) {
    $correct_conf = $current_page['handler']->conf;
  }

  // If no breadcrumb configuration was found, fallback to Drupal's default.
  if (isset($correct_conf) && $correct_conf['panels_breadcrumbs_state']) {
    $breadcrumb = panels_breadcrumbs_build_breadcrumb($correct_conf, $contexts);
  }

  $breadcrumb = drupal_get_breadcrumb();

  $block = new stdClass();
  $block->content = theme('breadcrumb', array('breadcrumb' => $breadcrumb));

  return $block;
}

?>

I just removed the else condition for drupal_get_breadcrumb.

das-peter’s picture

Issue summary: View changes
Status: Active » Needs review
StatusFileSize
new2.99 KB

How about this: Besides the panelizer configuration we also store the contexts used for this configuration and re-use it later if applicable?

hydra’s picture

Status: Needs review » Reviewed & tested by the community

This works for me, thanks! Way better then my hack :D

leksat’s picture

Status: Reviewed & tested by the community » Needs work

I have the same issue, but with a page_manager page implementing a site search.
The panels_breadcrumbs_build_breadcrumb() function is called twice, and the second call has incorrect contexts.

The #2 patch does not helped me, because the panels_breadcrumbs_panelizer_pre_render_alter() function (where the correct contexts are stored) is newer called.

To quick-fix this issue, I just added a static cache to the panels_breadcrumbs_build_breadcrumb() function. See https://github.com/AmazeeLabs/panels_breadcrumbs/commit/c73707
I'm not sure whether this is a correct solution, but actually it does the same job + saves some resources.

Cogax’s picture

#4 woked for me!

das-peter’s picture

Status: Needs work » Needs review
StatusFileSize
new3.22 KB

Extended the approach from #2.
Hope it covers more use cases now.
To properly test this we would need a whole bunch of possible scenarios.

rozh’s picture

I have site with panels_everywhere and panelizer.
Entityreference and taxonomy term contexts was added on node/%node page. Before applying patch from #6 tokens from contexts was empty. Now everything is great.

I'm ready to test some scenarios if you point me what kind of configuration we need to test.

rozh’s picture

Tokens doesn't work on panelized nodes with Panels Everywhere.

damienmckenna’s picture

Issue tags: +Panels Everywhere
damienmckenna’s picture

Sorry, wrong issue.

summit’s picture

Hi,
Is this patch https://www.drupal.org/node/2124813#comment-9143801 still valid?
Anyone else tested this?
greetings, Martijn

b-prod’s picture

Actualy I do not understand why the panels_breadcrumbs_page_breadcrumb_content_type_render() renders a breadcrumb that has already been set by the panels_breadcrumbs_panelizer_pre_render_alter().

This means that the breadcrumb is built 2 times, which is not good for performances.

So the breadcrumb should only be built if its configuration is manually defined in the pane configuration. Otherwise the drupal_get_breadcrumb() function should be called, getting the last breadcrumb set. Moreover, this ensure a better compatibility with others modules that may deal with the breadcrumb.

b-prod’s picture

The following patch stores the first built breadcrumb and returns it when the panels_breadcrumbs_build_breadcrumb() is called.

This means less processing (the breadcrumb is only built once), less memory usage (no context stored, only a small array containing the breadcrumb).

b-prod’s picture

Any news on this?

jdcrisamore’s picture

This fixed the issue I was having today with Taxonomy tokens not working with panels breadcrumbs! This should definitely be a candidate for the next release.

Thanks B-Prod!

b-prod’s picture

@jdcrisamore So could you please set this issue as Reviewed? Like that we could hope having this fixed in a future release.

sdstyles’s picture

Version: 7.x-2.1 » 7.x-2.x-dev
Status: Needs review » Reviewed & tested by the community

The patch works as expected.

The issue is present on 7.x-2.2 too, so changing version to 7.x-2.x-dev

IreneV’s picture

Will be added in next module release

  • IreneV committed 5877256 on 7.x-2.x
    Issue #2124813 by das-peter, B-Prod, Hydra, StryKaizer, rozh,...
IreneV’s picture

Status: Reviewed & tested by the community » Fixed
IreneV’s picture

Status: Fixed » Closed (fixed)