Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save filiphazardous/af56100a74e88839a35e0f6b6ba5c424 to your computer and use it in GitHub Desktop.
Save filiphazardous/af56100a74e88839a35e0f6b6ba5c424 to your computer and use it in GitHub Desktop.
Add nodes in block to context for viewsreference v2
diff -ru a/viewsreference/src/Plugin/Field/FieldFormatter/ViewsReferenceFieldFormatter.php b/viewsreference/src/Plugin/Field/FieldFormatter/ViewsReferenceFieldFormatter.php
--- a/src/Plugin/Field/FieldFormatter/ViewsReferenceFieldFormatter.php
+++ b/src/Plugin/Field/FieldFormatter/ViewsReferenceFieldFormatter.php
@@ -100,6 +100,9 @@
}
$node = \Drupal::routeMatch()->getParameter('node');
+ if ($items->getEntity() instanceof \Drupal\node\NodeInterface) {
+ $node = $items->getEntity();
+ }
$token_service = \Drupal::token();
if (is_array($arguments)) {
foreach ($arguments as $index => $argument) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment