Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save jcicero518/1b113ce3f7d3d7a7836677b528c8067d to your computer and use it in GitHub Desktop.

Select an option

Save jcicero518/1b113ce3f7d3d7a7836677b528c8067d to your computer and use it in GitHub Desktop.
Drupal 8 - Disable page for content type
<?php
use Drupal\node\NodeInterface;
/**
* Implements hook_ENTITY_TYPE_view().
*/
function mymodule_node_view(array &$build, NodeInterface $node, $display, $view_mode) {
if ($node->getType() === 'post') {
$build['#cache']['max-age'] = 0;
\Drupal::service('page_cache_kill_switch')->trigger();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment