Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save szeidler/2a7fb3e127ed9b28772206345fc3aa95 to your computer and use it in GitHub Desktop.
Save szeidler/2a7fb3e127ed9b28772206345fc3aa95 to your computer and use it in GitHub Desktop.
Show JSON API representation of node only on default and full view mode
diff --git a/modules/contenta_enhancements/contenta_enhancements.module b/modules/contenta_enhancements/contenta_enhancements.module
index d1b9951..8f0364b 100644
--- a/modules/contenta_enhancements/contenta_enhancements.module
+++ b/modules/contenta_enhancements/contenta_enhancements.module
@@ -362,7 +362,7 @@ function contenta_enhancements_toolbar_alter(&$items) {
function contenta_enhancements_node_view_alter(array &$build, NodeInterface $entity, EntityViewDisplayInterface $display) {
// Make sure the help pages are left alone.
// TODO: Use the concept of view modes to solve this problem, not this hack.
- if ($entity->bundle() === 'page') {
+ if ($entity->bundle() === 'page' || ($display->getMode() !== 'default' && $display->getMode() !== 'full')) {
return;
}
// Retrieve JSON API representation of this node.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment