New answers tagged

1

For Views rendering fields you can add the cache metadata to the field, so that it can be used already for the cached rows and then bubble up to the rendered view and block. /** * Implements hook_preprocess_views_view_field(). */ function mymodule_preprocess_views_view_field(array &$variables) { // target specific view and field $variables['#cache']...


0

You can add a backend class for the block, then add a cache context on language to that block. First, you need to get the config key for the view block. I believe it is views.view.[BLOCK_ID]. You can get the block ID in the advanced section of the view. Next, you add a custom class to the block. Here is how that is done for the system branding block. /** * ...


-2

After using multiple options, below code worked in my case for returning rest response. $url = \Drupal\Core\Url::fromRoute('entity.node.canonical', [ 'node' => $node->id(), ], $options); $url = $url->toString(true)->getGeneratedUrl(); Cheers!


Top 50 recent answers are included