Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save filiphazardous/2084576000ec27ae2ffdc2bc4e0739f6 to your computer and use it in GitHub Desktop.
Save filiphazardous/2084576000ec27ae2ffdc2bc4e0739f6 to your computer and use it in GitHub Desktop.
Add nodes in block to context for viewsreference
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 (!$node && $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