Answer the question
In order to leave comments, you need to log in
How to disable block-level caching or how to display dynamic information in Drupal 8?
In particular, there is a system-branding-block, I need to display the current page title in it and, accordingly, disable it in the page block. With the second one, everything is simple - redefine the template (although maybe there are some more correct methods?)
But what about the first one? In my own topic, I give this hook:
function mytheme_preprocess_block(&$vars) {
if ($vars['plugin_id'] != 'system_branding_block') return;
#Если текущий блок не system branding ничего не делаем, иначе берем тайтл от текущей ноды.
$node = $node = \Drupal::routeMatch()->getParameter('node');
if (!$node) return;
$vars['page_title'] = $node->get('title')->getValue()[0]['value'];
}
Answer the question
In order to leave comments, you need to log in
Good afternoon,
"Site branding" block is designed to display general information: site name, logo, slogan, etc.
It seems to me that you are using it for other purposes, tk. there is a Page title block for that. But the problem can be solved by adding the 'url' context block to the cache, or completely disabling the cache of your block.
https://www.drupal.org/docs/8/api/cache-api/cache-...
drupal.ru/node/127211
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question