diff --git a/src/Plugin/DisplayVariant/PanelsDisplayVariant.php b/src/Plugin/DisplayVariant/PanelsDisplayVariant.php index 08b5ffb..36e03ff 100644 --- a/src/Plugin/DisplayVariant/PanelsDisplayVariant.php +++ b/src/Plugin/DisplayVariant/PanelsDisplayVariant.php @@ -498,7 +498,7 @@ class PanelsDisplayVariant extends BlockDisplayVariant implements PluginWizardIn */ protected function getContextAsTokenData() { $data = array(); - foreach ($this->getContexts() as $context) { + foreach ($this->getContexts() as $context_id => $context) { // @todo Simplify this when token and typed data types are unified in // https://drupal.org/node/2163027. if (strpos($context->getContextDefinition()->getDataType(), 'entity:') === 0) { @@ -506,7 +506,18 @@ class PanelsDisplayVariant extends BlockDisplayVariant implements PluginWizardIn if ($token_type == 'taxonomy_term') { $token_type = 'term'; } - $data[$token_type] = $context->getContextValue(); + if ($context_value = $context->getContextValue()) { + $data[$token_type] = $context_value; + + // When the context ID does not match the token context, context values + // are added as a token alias. + // Needs support for multiple instances of the same token type with + // token in core, otherwise it will be ignored. + /** @see https://www.drupal.org/node/1920688 */ + if ($token_type != $context_id) { + $data[$token_type . '{' . $context_id . '}'] = $context_value; + } + } } } return $data;