function modal_page_preprocess_html in Modal 8.2
Same name and namespace in other branches
- 8.3 modal_page.module \modal_page_preprocess_html()
- 8 modal_page.module \modal_page_preprocess_html()
- 5.0.x modal_page.module \modal_page_preprocess_html()
- 4.0.x modal_page.module \modal_page_preprocess_html()
- 4.1.x modal_page.module \modal_page_preprocess_html()
Implements hook_preprocess_html().
File
- ./
modal_page.module, line 85 - Main file for the Modal Page.
Code
function modal_page_preprocess_html(&$variables) {
$correct_version = modal_page_is_entity_version();
if (empty($correct_version)) {
return FALSE;
}
$modal_exists = \Drupal::entityQuery('modal_page_modal')
->range(0, 1)
->execute();
if (empty($modal_exists)) {
return FALSE;
}
$modal_to_show = \Drupal::service('modal_page.modals')
->checkModalToShow();
if ($modal_to_show) {
$do_not_show_again = FALSE;
if (!empty($modal_to_show['do_not_show_again'])) {
$do_not_show_again = $modal_to_show['do_not_show_again'];
}
$title = $modal_to_show['title'];
$text = $modal_to_show['text'];
$delay_display = $modal_to_show['delay_display'];
$modal_size = $modal_to_show['modal_size'];
$button = $modal_to_show['button'];
$id = $modal_to_show['id'];
$open_modal_on_element_click = $modal_to_show['open_modal_on_element_click'];
$auto_open = $modal_to_show['auto_open'];
$variables['page_top']['slidedown_templates'] = [
'#theme' => 'modal_page_modal',
'#do_not_show_again' => $do_not_show_again,
'#title' => $title,
'#text' => $text,
'#delay_display' => $delay_display,
'#modal_size' => $modal_size,
'#button' => $button,
'#id' => $id,
];
$variables['#attached']['drupalSettings']['modal_page']['open_modal_on_element_click'] = $open_modal_on_element_click;
$variables['#attached']['drupalSettings']['modal_page']['auto_open'] = $auto_open;
if (isset($modal_to_show['do_not_show_again']) && !empty($modal_to_show['do_not_show_again'])) {
$variables['page_top']['slidedown_templates']['#do_not_show_again'] = $modal_to_show['do_not_show_again'];
}
}
}