Skip to content
Snippets Groups Projects

Issue #3382310: Multiple contextual filters / arguments are not supported when...

Open Issue #3382310: Multiple contextual filters / arguments are not supported when...
All threads resolved!
All threads resolved!
Files
3
@@ -101,6 +101,30 @@ class ViewsReferenceFieldFormatter extends FormatterBase {
}
$view->setDisplay($display_id);
$unserialized_data = unserialize($item->getValue()['data'], ['allowed_classes' => FALSE]);
$arguments = !empty($unserialized_data['argument']) ? explode('/', $unserialized_data['argument']) : [];
if ($arguments) {
// Get the view display.
$display = $view->storage->getDisplay($display_id);
// Contextual arguments are set to default if they are not overridden.
if (empty($display['display_options']['arguments'])) {
$default_display = $view->storage->getDisplay('default');
// If no arguments found try to get the ones from default display.
$display['display_options']['arguments'] = $default_display['display_options']['arguments'];
}
$display_arguments = array_values($display['display_options']['arguments']);
// If no value has been provided for an argument, use the default
// value for displaying all results.
foreach ($arguments as $num => $argument) {
if ($argument === '' && !empty($display_arguments[$num]['exception']['value'])) {
$arguments[$num] = $display_arguments[$num]['exception']['value'];
}
}
$unserialized_data['argument'] = implode('/', $arguments);
}
$enabled_settings = array_filter($this->getFieldSetting('enabled_settings') ?? []);
// Add properties to the view so our hook_views_pre_build() implementation
@@ -108,7 +132,7 @@ class ViewsReferenceFieldFormatter extends FormatterBase {
// behaviour in views. The hook_views_pre_build() needs to know if the
// view was part of a viewsreference field or not.
$view->element['#viewsreference'] = [
'data' => !empty($item->getValue()['data']) ? unserialize($item->getValue()['data'], ['allowed_classes' => FALSE]) : [],
'data' => $unserialized_data,
'enabled_settings' => $enabled_settings,
'parent_entity_type' => $parent_entity_type,
'parent_entity_id' => $parent_entity_id,
Loading