Last active
April 20, 2022 21:39
-
-
Save mecmartini/ad7d712c3773d0371f838e9a6d3185a6 to your computer and use it in GitHub Desktop.
Drupal 8 - Disable page for content type
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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