Forked from mecmartini/drupal-8-disable-page-for-content-type.php
Created
April 20, 2022 21:39
-
-
Save jcicero518/1b113ce3f7d3d7a7836677b528c8067d 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