2

I have Drupal setup using multisite so that the contents vary with sub domain. I need to use 'url.site' in 'cache context'. But cache context array contains 'url.site' only for node pages. In home page it contains:

Array ( 
   [0] => languages:language_interface 
   [1] => theme 
   [2] => user.permissions 
)

I think overriding function getCacheableRenderArray() with the below code will fix the issue.

if (!in_array('url.site', $elements['#cache']['contexts'])) {
  $elements['#cache']['contexts'][] = 'url.site';
}

How can I override the above mentioned array values using Drupal's default method?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.