Skip to content

Commit

Permalink
Issue #2658688 by slashrsm: Messages are not displayed in iFrame and …
Browse files Browse the repository at this point in the history
…Modal displays
  • Loading branch information
slashrsm committed Feb 1, 2016
1 parent 75249ff commit 50b7435
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
24 changes: 24 additions & 0 deletions entity_browser.module
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,27 @@ function entity_browser_form_alter(&$form, FormStateInterface &$form_state) {
];
}
}

/**
* Implements hook_preprocess_page__entity_browser__iframe().
*
* Tries to figure out where messages block lives and display it separately.
*/
function entity_browser_preprocess_page__entity_browser__iframe(&$variables) {
$blocks = \Drupal::entityTypeManager()->getStorage('block')->loadByProperties([
'theme' => \Drupal::theme()->getActiveTheme()->getName(),
'plugin' => 'system_messages_block',
]);
if ($messages = current($blocks)) {
$variables['messages'] = $variables['page'][$messages->getRegion()][$messages->id()];
}
}

/**
* Implements hook_preprocess_page__entity_browser__modal().
*
* Tries to figure out where messages block lives and display it separately.
*/
function entity_browser_preprocess_page__entity_browser__modal(&$variables) {
entity_browser_preprocess_page__entity_browser__iframe($variables);
}
9 changes: 9 additions & 0 deletions templates/page--entity-browser--iframe.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@
#}
<div class="layout-container">

{#
We ommit most of the regions in this template, which generally includes
messages too. Since this is not desired we try to figure out where messages
live and display them separately.
@see entity_browser_preprocess_page__entity_browser__iframe()
#}
{{ messages }}

<main role="main">
<a id="main-content" tabindex="-1"></a>{# link is in html.html.twig #}

Expand Down

0 comments on commit 50b7435

Please sign in to comment.