Last active
October 23, 2020 17:43
-
-
Save crittermike/149db0058375a8eba3bffcc878e73d48 to your computer and use it in GitHub Desktop.
Add a query_args cache context to the header block so that the cache is dependent on query string.
This file contains 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 | |
function MODULENAME_block_build_alter(array &$build, \Drupal\Core\Block\BlockPluginInterface $block) { | |
// Add the 'query args' cache context to the header block. | |
if ($this_block_is_the_header_block) { // @TODO: Make this line work. | |
$build['#cache']['contexts'][] = 'url.query_args'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment