-2

I need to hide the footer region on all pages with url /people/. Something like with the blocks you put show only in /people/*.

1 Answer 1

0

You can use hook_preprocess_page() hook (.modue/.theme file) to hide footer region conditionally:

function Mymodulename_preprocess_page(&$vars) {
  $vars['display_footer_region'] = true;
  $current_path = \Drupal::service('path.current')->getPath();
  $ex_string = '/people';
  // set the display_footer_region false conditionally
  if (strpos($current_path, $ex_string) !== false) {
    $vars['display_footer_region'] = false;
  }  
  
}

Then go to page.html.twig & add the footer region inside condition:

{% if display_footer_region == true %}
  {{ page.footer }}
{% endif %}

Make sure override the page.html.twig inside the custom theme

2
  • Can this hook be used from the .theme?
    – Yohan
    Nov 16 at 21:32
  • Yes you can add hook .in theme file as well like this: Mythemename_preprocess_page(&$vars)
    – mini
    Nov 17 at 4:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.