I don't want to show blocks inside some pages, and I can't touch the theme files.

Is there any way to do this programmatically inside a module?

  • it can also be done through the configuration of the individual blocks you want to limit... without any code.
    – Geoff
    Commented Jan 23, 2015 at 20:41

2 Answers 2


You can use hook_block_list_alter() to hide the blocks in your module code. See docs for more information on how to achieve this. This is the the alter for the function Drupal used to hide/show blocks.

  • thanks man,, sorry for late but finaly your answer is correct and works for me Commented Jan 26, 2015 at 7:22
  1. You should not hide all blocks because system_block contains your page markup.
  2. You can use hook_page_build to hide unwanted blocks.

Your Answer

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

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