You are here

function view_mode_page_block_build_alter in View Mode Page 4.0.x

Same name and namespace in other branches
  1. 8.3 view_mode_page.module \view_mode_page_block_build_alter()
  2. 3.2.x view_mode_page.module \view_mode_page_block_build_alter()

Implements hook_block_build_alter().

Adds additional cache_contexts to the system_main_block, to prevent incorrect caching of a single view_mode (when using a path alias).

File

./view_mode_page.module, line 38
Contains view_mode_page module.

Code

function view_mode_page_block_build_alter(array &$build, BlockPluginInterface $block) {
  if ($block
    ->getBaseId() == 'system_main_block') {
    $build['#cache']['contexts'][] = 'url.path';
  }
}