Commit 0a4bbdc9 authored by Gorodkov Denis's avatar Gorodkov Denis

refactor cache context

parent 222d0f94
name: Cache context
description: Custom task
package: Tasks
type: module
core: 8.x
core_version_requirement: ^8 || ^9
<?php
/**
* Implements hook_node_view().
*/
function cache_context_node_view(array &$build, $node) {
if ($node->bundle() == 'people') {
$build["elements"]["#cache"]["contexts"][] = 'url.query_args';
}
}
/**
* Implements hook_preprocess().
*/
function cache_context_preprocess(&$variables, $hook) {
if ($hook == 'details' and $variables["element"]["#bundle"] == 'people' and $variables["element"]["#group_name"] == 'group_films') {
$get = \Drupal::request()->query->get('tab');
if ($get == 'films') {
$variables["attributes"]['open'] = '';
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment