2

I want to move status messages into a region, but I can't seem to get it to stop being output as part of the main content output.

I tried this:

function mytheme_preprocess_region(&$variables) {
  if ($variables['region'] == 'content' && isset($variables['elements']['messages'])) {
    unset($variables['elements']['messages']);
    //$variables['elements']['messages']['#printed'] = FALSE;
  }
}

While that removed it from the array, it is still being rendered.

1 Answer 1

5

at /admin/structure/block, you can find the block "Status Messages" and move it to the "- None-" region, or another region of your choosing.

3
  • edit nevermind, looks like the block placement didnt save or something. Moving the block now removes it from content.
    – Kevin
    Oct 26, 2016 at 16:54
  • 2
    @oknate, yes, messages are now in a block. The block gets the messages directly from drupal_get_messages() and no longer from the variable messages. The code from page.html.twig must be from an old version, it does not work like this anymore.
    – 4uk4
    Oct 26, 2016 at 16:56
  • OK, I have updated my answer to remove that portion. Thanks.
    – oknate
    Oct 26, 2016 at 17:06

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.