2

I put a custom block (develop for me) on sidebar first region for every page, every fine, but I want that this block not render on the home page.

On my module, I made this:

funtion mymodule_preprocess_page(&$variables) {
  if ($variables['is_front']) {
    unset($variables['page']['sidebar_first']);
  }
}

The sidebar not show, but the block already was rendered (I debug this code and the build function of my block was called before of mymodule_preprocess_page function). Then how I programmatically avoid that this block not render.

2 Answers 2

1

Got to /admin/structure/block on your domain. Click the configure button beside your block. In the lower part of the configuration form you have a section called visibility. One of the tabs in this section is labelled pages. This is where you configure where the block is permitted or forbidden to be rendered. In your case one would write <front> and choose the radio button labelled "Hide for the listed pages".

0

Maybe hook_block_view_alter(array &$build, \Drupal\Core\Block\BlockPluginInterface $block) ?

1
  • To make this answer useful, you should explain why you believe this hook will solve the OPs problem. Commented Feb 23, 2015 at 5:03

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.