getTitle($request, $route_match->getRouteObject());
if (!empty($page_title)) {
$variables['breadcrumb'][] = array(
'text' => $page_title
);
// Add cache context based on url.
$variables['#cache']['contexts'][] = 'url';
}
}
}
/**
* Implements hook_preprocess_HOOK() for page templates.
*/
function magazineplus_preprocess_page_title(&$variables) {
// Since the title and the shortcut link are both block level elements,
// positioning them next to each other is much simpler with a wrapper div.
if (!empty($variables['title_suffix']['add_or_remove_shortcut']) && $variables['title']) {
// Add a wrapper div using the title_prefix and title_suffix render
// elements.
$variables['title_prefix']['shortcut_wrapper'] = array(
'#markup' => '
',
'#weight' => 100,
);
$variables['title_suffix']['shortcut_wrapper'] = array(
'#markup' => '
',
'#weight' => -99,
);
// Make sure the shortcut link is the first item in title_suffix.
$variables['title_suffix']['add_or_remove_shortcut']['#weight'] = -100;
}
}
function magazineplus_preprocess_page(&$variables) {
$mt_display_fixed_site_name = theme_get_setting('display_fixed_site_name');
$mt_display_fixed_logo = theme_get_setting('display_fixed_logo');
if ($mt_display_fixed_site_name) {
$site_name = \Drupal::config('system.site')->get('name');
if (!empty($site_name)) {
$variables['mt_site_name'] = $site_name;
}
}
if ($mt_display_fixed_logo) {
$variables['mt_logo'] = theme_get_setting('logo.url');
}
$slideout = $variables['page']['slideout'];
$sidebar_first = $variables['page']['sidebar_first'];
$sidebar_second = $variables['page']['sidebar_second'];
$content_bottom_first = $variables['page']['content_bottom_first'];
$content_bottom_second = $variables['page']['content_bottom_second'];
$footer_top_first = $variables['page']['footer_top_first'];
$footer_top_second = $variables['page']['footer_top_second'];
$footer_bottom_first = $variables['page']['footer_bottom_first'];
$footer_bottom_second = $variables['page']['footer_bottom_second'];
$pre_content_first = $variables['page']['pre_content_first'];
$pre_content_second = $variables['page']['pre_content_second'];
$footer_first = $variables['page']['footer_first'];
$footer_second = $variables['page']['footer_second'];
$footer_third = $variables['page']['footer_third'];
$footer_fourth = $variables['page']['footer_fourth'];
$footer_fifth = $variables['page']['footer_fifth'];
$subfooter_second = $variables['page']['footer'];
$subfooter_first = $variables['page']['sub_footer_first'];
// Attach library to slideout region
if ($slideout) {
$variables['#attached']['library'][] = 'magazineplus/slideout-init';
}
// Insert variables into the page template.
// Pre Header
$variables['pre_header_layout_container'] = theme_get_setting('pre_header_layout_container');
// Header Top Highlighted
$variables['header_top_highlighted_layout_container'] = theme_get_setting('header_top_highlighted_layout_container');
$header_top_highlighted_first = $variables['page']['header_top_highlighted_first'];
$header_top_highlighted_second = $variables['page']['header_top_highlighted_second'];
if($header_top_highlighted_first && $header_top_highlighted_second) {
$variables['header_top_highlighted_first_grid_class'] = 'col-sm-8';
$variables['header_top_highlighted_second_grid_class'] = 'col-sm-4';
} elseif ($header_top_highlighted_first || $header_top_highlighted_second) {
$variables['header_top_highlighted_first_grid_class'] = 'col-md-12';
$variables['header_top_highlighted_second_grid_class'] = 'col-md-12';
}
// Header Top
$variables['header_top_layout_container'] = theme_get_setting('header_top_layout_container');
$header_top_first = $variables['page']['header_top_first'];
$header_top_second = $variables['page']['header_top_second'];
if($header_top_first && $header_top_second) {
$variables['header_top_first_grid_class'] = 'col-sm-8';
$variables['header_top_second_grid_class'] = 'col-sm-4';
} elseif ($header_top_first || $header_top_second) {
$variables['header_top_first_grid_class'] = 'col-md-12';
$variables['header_top_second_grid_class'] = 'col-md-12';
}
// Header
$variables['header_layout_container'] = theme_get_setting('header_layout_container');
$header_first = $variables['page']['header_first'];
$header = $variables['page']['header'];
$header_third = $variables['page']['header_third'];
if (($header_first && !$header && $header_third) || (!$header_first && $header && $header_third)) {
$variables['header_layout_columns_class'] = 'two-columns';
if ($variables['header_layout_container'] == 'container-fluid') {
$variables['header_first_grid_class'] = 'col-md-8 col-md-pull-4 col-lg-9 col-lg-pull-3';
$variables['header_second_grid_class'] = 'col-md-8 col-md-pull-4 col-lg-9 col-lg-pull-3';
$variables['header_third_grid_class'] = 'col-md-4 col-md-push-8 col-lg-3 col-lg-push-9';
} else {
$variables['header_first_grid_class'] = 'col-md-8 col-md-pull-4';
$variables['header_second_grid_class'] = 'col-md-8 col-md-pull-4';
$variables['header_third_grid_class'] = 'col-md-4 col-md-push-8';
}
} else if ($header_first && $header) {
if ($header_third) {
$variables['header_layout_columns_class'] = 'three-columns';
$variables['header_first_grid_class'] = 'col-md-3 col-md-pull-2 col-sm-8 col-sm-pull-4';
$variables['header_second_grid_class'] = 'col-md-7 col-md-pull-2 col-sm-12';
$variables['header_third_grid_class'] = 'col-md-2 col-md-push-10 col-sm-4 col-sm-push-8';
} else {
$variables['header_layout_columns_class'] = 'two-columns';
$variables['header_first_grid_class'] = 'col-md-4';
$variables['header_second_grid_class'] = 'col-md-8';
}
} else {
$variables['header_layout_columns_class'] = 'one-column';
$variables['header_first_grid_class'] = 'col-xs-12';
$variables['header_second_grid_class'] = 'col-xs-12';
$variables['header_third_grid_class'] = 'col-xs-12';
}
if ($variables['header_layout_container'] == 'container-fluid') {
$variables['header_layout_container_class'] = 'full-width';
} else {
$variables['header_layout_container_class'] = 'fixed-width';
}
// Banner
$variables['banner_layout_container'] = theme_get_setting('banner_layout_container');
// Content Top
$variables['content_top_layout_container'] = theme_get_setting('content_top_layout_container');
// Content Top Highlighted
$variables['content_top_highlighted_layout_container'] = theme_get_setting('content_top_highlighted_layout_container');
// Main Content Layout
if($sidebar_first && $sidebar_second) {
$variables['main_grid_class'] = 'col-md-6 col-md-push-3';
$variables['sidebar_first_grid_class'] = 'col-md-3 col-md-pull-6';
$variables['sidebar_second_grid_class'] = 'col-md-3';
} elseif ($sidebar_first && !$sidebar_second) {
$variables['main_grid_class'] = 'col-md-8 col-md-push-4';
$variables['sidebar_first_grid_class'] = 'col-md-4 col-md-pull-8';
$variables['sidebar_second_grid_class'] = '';
} elseif (!$sidebar_first && $sidebar_second) {
$variables['main_grid_class'] = 'col-md-8';
$variables['sidebar_first_grid_class'] = '';
$variables['sidebar_second_grid_class'] = 'col-md-4';
} else {
$variables['main_grid_class'] = 'col-md-12';
$variables['sidebar_first_grid_class'] = '';
$variables['sidebar_second_grid_class'] = '';
}
// Content Bottom
$variables['content_bottom_layout_container'] = theme_get_setting('content_bottom_layout_container');
if($content_bottom_second && $content_bottom_first) {
$variables['content_bottom_first_grid_class'] = 'col-md-5';
$variables['content_bottom_second_grid_class'] = 'col-md-5 col-md-offset-2';
} elseif ($content_bottom_second || $content_bottom_first) {
$variables['content_bottom_first_grid_class'] = 'col-md-12';
$variables['content_bottom_second_grid_class'] = 'col-md-12';
}
// Featured Top
$variables['featured_top_layout_container'] = theme_get_setting('featured_top_layout_container');
// Featured
$variables['featured_layout_container'] = theme_get_setting('featured_layout_container');
// Featured Bottom
$variables['featured_bottom_layout_container'] = theme_get_setting('featured_bottom_layout_container');
// Sub Featured
$variables['sub_featured_layout_container'] = theme_get_setting('sub_featured_layout_container');
// Highlighted
$variables['highlighted_layout_container'] = theme_get_setting('highlighted_layout_container');
// Highlighted Top
$variables['highlighted_top_layout_container'] = theme_get_setting('highlighted_top_layout_container');
// Pre Content
$variables['pre_content_layout_container'] = theme_get_setting('pre_content_layout_container');
if($pre_content_second && $pre_content_first) {
$variables['pre_content_first_grid_class'] = 'col-md-8';
$variables['pre_content_second_grid_class'] = 'col-md-4';
} elseif ($pre_content_second || $pre_content_first) {
$variables['pre_content_first_grid_class'] = 'col-md-12';
$variables['pre_content_second_grid_class'] = 'col-md-12';
}
// Footer Top
$variables['footer_top_layout_container'] = theme_get_setting('footer_top_layout_container');
if($footer_top_first && $footer_top_second) {
$variables['footer_top_regions'] = 'two-regions';
$variables['footer_top_first_grid_class'] = 'col-sm-6';
$variables['footer_top_second_grid_class'] = 'col-sm-6';
} elseif ($footer_top_second || $footer_top_first) {
$variables['footer_top_regions'] = 'one-region';
$variables['footer_top_first_grid_class'] = 'col-md-12';
$variables['footer_top_second_grid_class'] = 'col-md-12';
}
// Footer Layout
$variables['footer_layout_container'] = theme_get_setting('footer_layout_container');
if ($footer_fifth) {
if ($footer_first && $footer_second && $footer_third && $footer_fourth) {
$variables['footer_first_grid_class'] = 'col-sm-4 col-lg-2';
$variables['footer_second_grid_class'] = 'col-sm-4 col-lg-2';
$variables['footer_third_grid_class'] = 'col-sm-4 col-lg-2';
$variables['footer_fourth_grid_class'] = 'col-sm-6 col-lg-3';
$variables['footer_fifth_grid_class'] = 'col-sm-6 col-lg-3';
} elseif ((!$footer_first && $footer_second && $footer_third && $footer_fourth) || ($footer_first && !$footer_second && $footer_third && $footer_fourth)
|| ($footer_first && $footer_second && !$footer_third && $footer_fourth) || ($footer_first && $footer_second && $footer_third && !$footer_fourth)) {
$variables['footer_first_grid_class'] = 'col-sm-6 col-md-3';
$variables['footer_second_grid_class'] = 'col-sm-6 col-md-3';
$variables['footer_third_grid_class'] = 'col-sm-6 col-md-3';
$variables['footer_fourth_grid_class'] = 'col-sm-6 col-md-3';
$variables['footer_fifth_grid_class'] = 'col-sm-6 col-md-3';
} elseif ((!$footer_first && !$footer_second && $footer_third && $footer_fourth) || (!$footer_first && $footer_second && !$footer_third && $footer_fourth)
|| (!$footer_first && $footer_second && $footer_third && !$footer_fourth) || ($footer_first && !$footer_second && !$footer_third && $footer_fourth)
|| ($footer_first && !$footer_second && $footer_third && !$footer_fourth) || ($footer_first && $footer_second && !$footer_third && !$footer_fourth)) {
$variables['footer_first_grid_class'] = 'col-sm-4';
$variables['footer_second_grid_class'] = 'col-sm-4';
$variables['footer_third_grid_class'] = 'col-sm-4';
$variables['footer_fourth_grid_class'] = 'col-sm-4';
$variables['footer_fifth_grid_class'] = 'col-sm-4';
} elseif (($footer_first && !$footer_second && !$footer_third && !$footer_fourth) || (!$footer_first && $footer_second && !$footer_third && !$footer_fourth)
|| (!$footer_first && !$footer_second && $footer_third && !$footer_fourth) || (!$footer_first && !$footer_second && !$footer_third && $footer_fourth)) {
$variables['footer_first_grid_class'] = 'col-sm-6';
$variables['footer_second_grid_class'] = 'col-sm-6';
$variables['footer_third_grid_class'] = 'col-sm-6';
$variables['footer_fourth_grid_class'] = 'col-sm-6';
$variables['footer_fifth_grid_class'] = 'col-sm-6';
} else {
$variables['footer_fifth_grid_class'] = 'col-sm-12';
}
} else {
if ($footer_first && $footer_second && $footer_third && $footer_fourth) {
$variables['footer_first_grid_class'] = 'col-sm-6 col-md-3';
$variables['footer_second_grid_class'] = 'col-sm-6 col-md-3';
$variables['footer_third_grid_class'] = 'col-sm-6 col-md-3';
$variables['footer_fourth_grid_class'] = 'col-sm-6 col-md-3';
} elseif ((!$footer_first && $footer_second && $footer_third && $footer_fourth) || ($footer_first && !$footer_second && $footer_third && $footer_fourth)
|| ($footer_first && $footer_second && !$footer_third && $footer_fourth) || ($footer_first && $footer_second && $footer_third && !$footer_fourth)) {
$variables['footer_first_grid_class'] = 'col-sm-4';
$variables['footer_second_grid_class'] = 'col-sm-4';
$variables['footer_third_grid_class'] = 'col-sm-4';
$variables['footer_fourth_grid_class'] = 'col-sm-4';
} elseif ((!$footer_first && !$footer_second && $footer_third && $footer_fourth) || (!$footer_first && $footer_second && !$footer_third && $footer_fourth)
|| (!$footer_first && $footer_second && $footer_third && !$footer_fourth) || ($footer_first && !$footer_second && !$footer_third && $footer_fourth)
|| ($footer_first && !$footer_second && $footer_third && !$footer_fourth) || ($footer_first && $footer_second && !$footer_third && !$footer_fourth)) {
$variables['footer_first_grid_class'] = 'col-sm-6';
$variables['footer_second_grid_class'] = 'col-sm-6';
$variables['footer_third_grid_class'] = 'col-sm-6';
$variables['footer_fourth_grid_class'] = 'col-sm-6';
} else {
$variables['footer_first_grid_class'] = 'col-sm-12';
$variables['footer_second_grid_class'] = 'col-sm-12';
$variables['footer_third_grid_class'] = 'col-sm-12';
$variables['footer_fourth_grid_class'] = 'col-sm-12';
}
}
if (($footer_first && $footer_second) && (($footer_third && $footer_fourth && !$footer_fifth) || ($footer_third && !$footer_fourth && $footer_fifth) || (!$footer_third && $footer_fourth && $footer_fifth))) {
$variables['footer_4_columns_clearfix_first'] = "visible-sm-block";
} else {
$variables['footer_4_columns_clearfix_first'] = "visible-xs-block";
}
if (($footer_fourth && $footer_fifth) && (($footer_first && $footer_second && !$footer_third) || ($footer_first && !$footer_second && $footer_third) || (!$footer_first && $footer_second && $footer_third))) {
$variables['footer_4_columns_clearfix_second'] = "visible-sm-block";
} else {
$variables['footer_4_columns_clearfix_second'] = "visible-xs-block";
}
if ($footer_first && $footer_second && $footer_third && $footer_fourth && $footer_fifth) {
$variables['footer_5_columns_clearfix'] = "visible-sm-block visible-md-block";
} else {
$variables['footer_5_columns_clearfix'] = "visible-xs-block";
}
//Footer Bottom
$variables['footer_bottom_layout_container'] = theme_get_setting('footer_bottom_layout_container');
if($footer_bottom_second && $footer_bottom_first) {
$variables['footer_bottom_first_grid_class'] = 'col-md-4';
$variables['footer_bottom_second_grid_class'] = 'col-md-8';
} elseif ($footer_bottom_second || $footer_bottom_first) {
$variables['footer_bottom_second_grid_class'] = 'col-md-12 text-center';
$variables['footer_bottom_first_grid_class'] = 'col-md-12 text-center';
}
// Subfooter
$variables['subfooter_layout_container'] = theme_get_setting('subfooter_layout_container');
if($subfooter_second && $subfooter_first) {
$variables['subfooter_first_grid_class'] = 'col-md-6';
$variables['subfooter_second_grid_class'] = 'col-md-6';
} elseif ($subfooter_second || $subfooter_first) {
$variables['subfooter_second_grid_class'] = 'col-md-12 text-center';
$variables['subfooter_first_grid_class'] = 'col-md-12 text-center';
}
// Animations
$animations_state = theme_get_setting('animations_state');
$variables['header_top_highlighted_animation_effect'] = theme_get_setting('header_top_highlighted_animation_effect');
if ($animations_state && $variables['header_top_highlighted_animation_effect'] != "no-animation") {
$variables['header_top_highlighted_animations'] = "enabled";
} else {
$variables['header_top_highlighted_animations'] = "disabled";
}
$variables['header_top_animation_effect'] = theme_get_setting('header_top_animation_effect');
if ($animations_state && $variables['header_top_animation_effect'] != "no-animation") {
$variables['header_top_animations'] = "enabled";
} else {
$variables['header_top_animations'] = "disabled";
}
$variables['content_top_animation_effect'] = theme_get_setting('content_top_animation_effect');
if ($animations_state && $variables['content_top_animation_effect'] != "no-animation") {
$variables['content_top_animations'] = "enabled";
} else {
$variables['content_top_animations'] = "disabled";
}
$variables['content_top_highlighted_animation_effect'] = theme_get_setting('content_top_highlighted_animation_effect');
if ($animations_state && $variables['content_top_highlighted_animation_effect'] != "no-animation") {
$variables['content_top_highlighted_animations'] = "enabled";
} else {
$variables['content_top_highlighted_animations'] = "disabled";
}
$variables['main_content_animation_effect'] = theme_get_setting('main_content_animation_effect');
if ($animations_state && $variables['main_content_animation_effect'] != "no-animation") {
$variables['main_content_animations'] = "enabled";
} else {
$variables['main_content_animations'] = "disabled";
}
$variables['sidebar_first_animation_effect'] = theme_get_setting('sidebar_first_animation_effect');
if ($animations_state && $variables['sidebar_first_animation_effect'] != "no-animation") {
$variables['sidebar_first_animations'] = "enabled";
} else {
$variables['sidebar_first_animations'] = "disabled";
}
$variables['sidebar_second_animation_effect'] = theme_get_setting('sidebar_second_animation_effect');
if ($animations_state && $variables['sidebar_second_animation_effect'] != "no-animation") {
$variables['sidebar_second_animations'] = "enabled";
} else {
$variables['sidebar_second_animations'] = "disabled";
}
$variables['content_bottom_animation_effect'] = theme_get_setting('content_bottom_animation_effect');
if ($animations_state && $variables['content_bottom_animation_effect'] != "no-animation") {
$variables['content_bottom_animations'] = "enabled";
} else {
$variables['content_bottom_animations'] = "disabled";
}
$variables['featured_top_animation_effect'] = theme_get_setting('featured_top_animation_effect');
if ($animations_state && $variables['featured_top_animation_effect'] != "no-animation") {
$variables['featured_top_animations'] = "enabled";
} else {
$variables['featured_top_animations'] = "disabled";
}
$variables['featured_animation_effect'] = theme_get_setting('featured_animation_effect');
if ($animations_state && $variables['featured_animation_effect'] != "no-animation") {
$variables['featured_animations'] = "enabled";
} else {
$variables['featured_animations'] = "disabled";
}
$variables['featured_bottom_animation_effect'] = theme_get_setting('featured_bottom_animation_effect');
if ($animations_state && $variables['featured_bottom_animation_effect'] != "no-animation") {
$variables['featured_bottom_animations'] = "enabled";
} else {
$variables['featured_bottom_animations'] = "disabled";
}
$variables['sub_featured_animation_effect'] = theme_get_setting('sub_featured_animation_effect');
if ($animations_state && $variables['sub_featured_animation_effect'] != "no-animation") {
$variables['sub_featured_animations'] = "enabled";
} else {
$variables['sub_featured_animations'] = "disabled";
}
$variables['highlighted_animation_effect'] = theme_get_setting('highlighted_animation_effect');
if ($animations_state && $variables['highlighted_animation_effect'] != "no-animation") {
$variables['highlighted_animations'] = "enabled";
} else {
$variables['highlighted_animations'] = "disabled";
}
$variables['highlighted_top_animation_effect'] = theme_get_setting('highlighted_top_animation_effect');
if ($animations_state && $variables['highlighted_top_animation_effect'] != "no-animation") {
$variables['highlighted_top_animations'] = "enabled";
} else {
$variables['highlighted_top_animations'] = "disabled";
}
$variables['pre_content_animation_effect'] = theme_get_setting('pre_content_animation_effect');
if ($animations_state && $variables['pre_content_animation_effect'] != "no-animation") {
$variables['pre_content_animations'] = "enabled";
} else {
$variables['pre_content_animations'] = "disabled";
}
$variables['footer_top_animation_effect'] = theme_get_setting('footer_top_animation_effect');
if ($animations_state && $variables['footer_top_animation_effect'] != "no-animation") {
$variables['footer_top_animations'] = "enabled";
} else {
$variables['footer_top_animations'] = "disabled";
}
$variables['footer_animation_effect'] = theme_get_setting('footer_animation_effect');
if ($animations_state && $variables['footer_animation_effect'] != "no-animation") {
$variables['footer_animations'] = "enabled";
} else {
$variables['footer_animations'] = "disabled";
}
// Region Background Color
$variables['slideout_background_color'] = theme_get_setting('slideout_background_color');
$variables['pre_header_background_color'] = theme_get_setting('pre_header_background_color');
$variables['header_top_highlighted_background_color'] = theme_get_setting('header_top_highlighted_background_color');
$variables['header_top_background_color'] = theme_get_setting('header_top_background_color');
$variables['header_background_color'] = theme_get_setting('header_background_color');
$variables['banner_background_color'] = theme_get_setting('banner_background_color');
$variables['content_top_background_color'] = theme_get_setting('content_top_background_color');
$variables['content_top_highlighted_background_color'] = theme_get_setting('content_top_highlighted_background_color');
$variables['content_bottom_background_color'] = theme_get_setting('content_bottom_background_color');
$variables['featured_top_background_color'] = theme_get_setting('featured_top_background_color');
$variables['featured_background_color'] = theme_get_setting('featured_background_color');
$variables['featured_bottom_background_color'] = theme_get_setting('featured_bottom_background_color');
$variables['sub_featured_background_color'] = theme_get_setting('sub_featured_background_color');
$variables['highlighted_background_color'] = theme_get_setting('highlighted_background_color');
$variables['highlighted_top_background_color'] = theme_get_setting('highlighted_top_background_color');
$variables['pre_content_background_color'] = theme_get_setting('pre_content_background_color');
$variables['footer_top_background_color'] = theme_get_setting('footer_top_background_color');
$variables['footer_background_color'] = theme_get_setting('footer_background_color');
$variables['footer_bottom_background_color'] = theme_get_setting('footer_bottom_background_color');
$variables['subfooter_background_color'] = theme_get_setting('subfooter_background_color');
//Region Separator
$variables['content_top_highlighted_separator'] = theme_get_setting('content_top_highlighted_separator');
$variables['pre_content_separator'] = theme_get_setting('pre_content_separator');
$variables['main_content_separator'] = theme_get_setting('main_content_separator');
$variables['content_bottom_separator'] = theme_get_setting('content_bottom_separator');
$variables['featured_top_separator'] = theme_get_setting('featured_top_separator');
$variables['featured_separator'] = theme_get_setting('featured_separator');
$variables['featured_bottom_separator'] = theme_get_setting('featured_bottom_separator');
$variables['sub_featured_separator'] = theme_get_setting('sub_featured_separator');
$variables['highlighted_top_separator'] = theme_get_setting('highlighted_top_separator');
$variables['highlighted_separator'] = theme_get_setting('highlighted_separator');
$variables['footer_top_separator'] = theme_get_setting('footer_top_separator');
$variables['footer_separator'] = theme_get_setting('footer_separator');
$variables['footer_bottom_separator'] = theme_get_setting('footer_bottom_separator');
$variables['subfooter_separator'] = theme_get_setting('subfooter_separator');
// Region Blocks Paddings
$variables['slideout_blocks_paddings'] = theme_get_setting('slideout_blocks_paddings');
$variables['pre_header_blocks_paddings'] = theme_get_setting('pre_header_blocks_paddings');
$variables['header_top_highlighted_blocks_paddings'] = theme_get_setting('header_top_highlighted_blocks_paddings');
$variables['header_top_blocks_paddings'] = theme_get_setting('header_top_blocks_paddings');
$variables['header_blocks_paddings'] = theme_get_setting('header_blocks_paddings');
$variables['banner_blocks_paddings'] = theme_get_setting('banner_blocks_paddings');
$variables['content_top_blocks_paddings'] = theme_get_setting('content_top_blocks_paddings');
$variables['content_top_highlighted_blocks_paddings'] = theme_get_setting('content_top_highlighted_blocks_paddings');
$variables['pre_content_blocks_paddings'] = theme_get_setting('pre_content_blocks_paddings');
$variables['main_content_blocks_paddings'] = theme_get_setting('main_content_blocks_paddings');
$variables['sidebar_first_blocks_paddings'] = theme_get_setting('sidebar_first_blocks_paddings');
$variables['sidebar_second_blocks_paddings'] = theme_get_setting('sidebar_second_blocks_paddings');
$variables['content_bottom_blocks_paddings'] = theme_get_setting('content_bottom_blocks_paddings');
$variables['featured_top_blocks_paddings'] = theme_get_setting('featured_top_blocks_paddings');
$variables['featured_blocks_paddings'] = theme_get_setting('featured_blocks_paddings');
$variables['featured_bottom_blocks_paddings'] = theme_get_setting('featured_bottom_blocks_paddings');
$variables['sub_featured_blocks_paddings'] = theme_get_setting('sub_featured_blocks_paddings');
$variables['highlighted_top_blocks_paddings'] = theme_get_setting('highlighted_top_blocks_paddings');
$variables['highlighted_blocks_paddings'] = theme_get_setting('highlighted_blocks_paddings');
$variables['footer_top_blocks_paddings'] = theme_get_setting('footer_top_blocks_paddings');
$variables['footer_blocks_paddings'] = theme_get_setting('footer_blocks_paddings');
$variables['footer_bottom_blocks_paddings'] = theme_get_setting('footer_bottom_blocks_paddings');
$variables['subfooter_blocks_paddings'] = theme_get_setting('subfooter_blocks_paddings');
// Region Region Paddings
$variables['slideout_region_paddings'] = theme_get_setting('slideout_region_paddings');
$variables['pre_header_region_paddings'] = theme_get_setting('pre_header_region_paddings');
$variables['header_top_highlighted_region_paddings'] = theme_get_setting('header_top_highlighted_region_paddings');
$variables['header_top_region_paddings'] = theme_get_setting('header_top_region_paddings');
$variables['header_region_paddings'] = theme_get_setting('header_region_paddings');
$variables['banner_region_paddings'] = theme_get_setting('banner_region_paddings');
$variables['content_top_region_paddings'] = theme_get_setting('content_top_region_paddings');
$variables['content_top_highlighted_region_paddings'] = theme_get_setting('content_top_highlighted_region_paddings');
$variables['pre_content_region_paddings'] = theme_get_setting('pre_content_region_paddings');
$variables['main_content_region_paddings'] = theme_get_setting('main_content_region_paddings');
$variables['sidebar_first_region_paddings'] = theme_get_setting('sidebar_first_region_paddings');
$variables['sidebar_second_region_paddings'] = theme_get_setting('sidebar_second_region_paddings');
$variables['content_bottom_region_paddings'] = theme_get_setting('content_bottom_region_paddings');
$variables['featured_top_region_paddings'] = theme_get_setting('featured_top_region_paddings');
$variables['featured_region_paddings'] = theme_get_setting('featured_region_paddings');
$variables['featured_bottom_region_paddings'] = theme_get_setting('featured_bottom_region_paddings');
$variables['sub_featured_region_paddings'] = theme_get_setting('sub_featured_region_paddings');
$variables['highlighted_top_region_paddings'] = theme_get_setting('highlighted_top_region_paddings');
$variables['highlighted_region_paddings'] = theme_get_setting('highlighted_region_paddings');
$variables['footer_top_region_paddings'] = theme_get_setting('footer_top_region_paddings');
$variables['footer_region_paddings'] = theme_get_setting('footer_region_paddings');
$variables['footer_bottom_region_paddings'] = theme_get_setting('footer_bottom_region_paddings');
$variables['subfooter_region_paddings'] = theme_get_setting('subfooter_region_paddings');
//Load to-top library
$variables['scroll_to_top_display'] = theme_get_setting('scroll_to_top_display');
$variables['scroll_to_top_region'] = theme_get_setting('scroll_to_top_region');
if ($variables['scroll_to_top_display']) {
$variables['#attached']['library'][] = 'magazineplus/to-top';
$variables['scroll_to_top_icon'] = theme_get_setting('scroll_to_top_icon');
}
//fixed header
$variables['fixed_header'] = theme_get_setting('fixed_header');
}
function magazineplus_page_attachments_alter(&$page) {
// Slideshow's caption Opacity
$slideshow_caption_opacity = (int) theme_get_setting('rs_slideshow_caption_opacity')/100;
$page['#attached']['drupalSettings']['magazineplus']['slideshowCaptionOpacity'] = $slideshow_caption_opacity;
// Full Screen Slideshow
$slideshow_fullscreen_effect_time = (int) theme_get_setting('rs_slideshow_fullscreen_effect_time')*1000;
$slideshow_fullscreen_navigation_style = theme_get_setting('rs_slideshow_fullscreen_navigation_style');
$slideshow_fullscreen_bullets_position = theme_get_setting('rs_slideshow_fullscreen_bullets_position');
$slideshow_fullscreen_touch_swipe = theme_get_setting('rs_slideshow_fullscreen_touch_swipe');
$page['#attached']['drupalSettings']['magazineplus']['sliderRevolutionFullScreenInit']['slideshowFullScreenEffectTime'] = $slideshow_fullscreen_effect_time;
$page['#attached']['drupalSettings']['magazineplus']['sliderRevolutionFullScreenInit']['slideshowFullScreenNavigationStyle'] = $slideshow_fullscreen_navigation_style;
$page['#attached']['drupalSettings']['magazineplus']['sliderRevolutionFullScreenInit']['slideshowFullScreenBulletsPosition'] = $slideshow_fullscreen_bullets_position;
if ($slideshow_fullscreen_touch_swipe) {
$page['#attached']['drupalSettings']['magazineplus']['sliderRevolutionFullScreenInit']['slideshowFullScreenTouchSwipe'] = "on";
} else {
$page['#attached']['drupalSettings']['magazineplus']['sliderRevolutionFullScreenInit']['slideshowFullScreenTouchSwipe'] = "off";
}
// Boxed Width Slideshow
$slideshow_boxedwidth_effect_time = (int) theme_get_setting('rs_slideshow_boxedwidth_effect_time')*1000;
$slideshow_boxedwidth_initial_height = (int) theme_get_setting('rs_slideshow_boxedwidth_initial_height');
$slideshow_boxedwidth_navigation_style = theme_get_setting('rs_slideshow_boxedwidth_navigation_style');
$slideshow_boxedwidth_bullets_position = theme_get_setting('rs_slideshow_boxedwidth_bullets_position');
$slideshow_boxedwidth_touch_swipe = theme_get_setting('rs_slideshow_boxedwidth_touch_swipe');
$page['#attached']['drupalSettings']['magazineplus']['sliderRevolutionBoxedWidthInit']['slideshowBoxedWidthEffectTime'] = $slideshow_boxedwidth_effect_time;
$page['#attached']['drupalSettings']['magazineplus']['sliderRevolutionBoxedWidthInit']['slideshowBoxedWidthInitialHeight'] = $slideshow_boxedwidth_initial_height;
$page['#attached']['drupalSettings']['magazineplus']['sliderRevolutionBoxedWidthInit']['slideshowBoxedWidthNavigationStyle'] = $slideshow_boxedwidth_navigation_style;
$page['#attached']['drupalSettings']['magazineplus']['sliderRevolutionBoxedWidthInit']['slideshowBoxedWidthBulletsPosition'] = $slideshow_boxedwidth_bullets_position;
if ($slideshow_boxedwidth_touch_swipe) {
$page['#attached']['drupalSettings']['magazineplus']['sliderRevolutionBoxedWidthInit']['slideshowBoxedWidthTouchSwipe'] = "on";
} else {
$page['#attached']['drupalSettings']['magazineplus']['sliderRevolutionBoxedWidthInit']['slideshowBoxedWidthTouchSwipe'] = "off";
}
// Internal Banner Slideshow
$slideshow_internal_banner_effect_time = (int) theme_get_setting('rs_slideshow_internal_effect_time')*1000;
$slideshow_internal_banner_initial_height = (int) theme_get_setting('rs_slideshow_internal_initial_height');
$slideshow_internal_navigation_style = theme_get_setting('rs_slideshow_internal_navigation_style');
$slideshow_internal_banner_bullets_position = theme_get_setting('rs_slideshow_internal_bullets_position');
$slideshow_internal_banner_touch_swipe = theme_get_setting('rs_slideshow_internal_banner_touch_swipe');
$page['#attached']['drupalSettings']['magazineplus']['sliderRevolutionInternalBannerInit']['slideshowInternalBannerEffectTime'] = $slideshow_internal_banner_effect_time;
$page['#attached']['drupalSettings']['magazineplus']['sliderRevolutionInternalBannerInit']['slideshowInternalBannerInitialHeight'] = $slideshow_internal_banner_initial_height;
$page['#attached']['drupalSettings']['magazineplus']['sliderRevolutionInternalBannerInit']['slideshowInternalBannerNavigationStyle'] = $slideshow_internal_navigation_style;
$page['#attached']['drupalSettings']['magazineplus']['sliderRevolutionInternalBannerInit']['slideshowInternalBannerBulletsPosition'] = $slideshow_internal_banner_bullets_position;
if ($slideshow_internal_banner_touch_swipe) {
$page['#attached']['drupalSettings']['magazineplus']['sliderRevolutionInternalBannerInit']['slideshowInternalBannerTouchSwipe'] = "on";
} else {
$page['#attached']['drupalSettings']['magazineplus']['sliderRevolutionInternalBannerInit']['slideshowInternalBannerTouchSwipe'] = "off";
}
// Posts carousel
$owl_posts_autoplay = theme_get_setting('owl_posts_autoplay');
$owl_posts_effect_time = (int) theme_get_setting('owl_posts_effect_time')*1000;
$page['#attached']['drupalSettings']['magazineplus']['owlCarouselPostsInit']['owlPostsAutoPlay'] = $owl_posts_autoplay;
$page['#attached']['drupalSettings']['magazineplus']['owlCarouselPostsInit']['owlPostsEffectTime'] = $owl_posts_effect_time;
// Square Posts carousel
$owl_square_posts_autoplay = theme_get_setting('owl_square_posts_autoplay');
$owl_square_posts_effect_time = (int) theme_get_setting('owl_square_posts_effect_time')*1000;
$page['#attached']['drupalSettings']['magazineplus']['owlCarouselSquarePostsInit']['owlSquarePostsAutoPlay'] = $owl_square_posts_autoplay;
$page['#attached']['drupalSettings']['magazineplus']['owlCarouselSquarePostsInit']['owlSquarePostsEffectTime'] = $owl_square_posts_effect_time;
// Posts slider
$owl_posts_slider_autoplay = theme_get_setting('owl_posts_slider_autoplay');
$owl_posts_slider_effect_time = (int) theme_get_setting('owl_posts_slider_effect_time')*1000;
$page['#attached']['drupalSettings']['magazineplus']['owlCarouselPostsSliderInit']['owlPostsSliderAutoPlay'] = $owl_posts_slider_autoplay;
$page['#attached']['drupalSettings']['magazineplus']['owlCarouselPostsSliderInit']['owlPostsSliderEffectTime'] = $owl_posts_slider_effect_time;
// Testimonials carousel
$owl_testimonials_autoplay = theme_get_setting('owl_testimonials_autoplay');
$owl_testimonials_effect_time = (int) theme_get_setting('owl_testimonials_effect_time')*1000;
$page['#attached']['drupalSettings']['magazineplus']['owlCarouselTestimonialsInit']['owlTestimonialsAutoPlay'] = $owl_testimonials_autoplay;
$page['#attached']['drupalSettings']['magazineplus']['owlCarouselTestimonialsInit']['owlTestimonialsEffectTime'] = $owl_testimonials_effect_time;
//In page slider
$in_page_slider_effect = theme_get_setting('in_page_slider_effect');
$page['#attached']['drupalSettings']['magazineplus']['flexsliderInPageInit']['inPageSliderEffect'] = $in_page_slider_effect;
// Transparent Header Opacity
$transparent_header_opacity = (int) theme_get_setting('transparent_header_opacity')/100;
$page['#attached']['drupalSettings']['magazineplus']['transparentHeader']['transparentHeaderOpacity'] = $transparent_header_opacity;
// Slideout
$slideout_side = theme_get_setting('slideout_side');
$slideout_touch_swipe = theme_get_setting('slideout_touch_swipe');
$page['#attached']['drupalSettings']['magazineplus']['slideoutInit']['slideoutSide'] = $slideout_side;
if ($slideout_touch_swipe) {
$page['#attached']['drupalSettings']['magazineplus']['slideoutInit']['slideoutTouchSwipe'] = true;
} else {
$page['#attached']['drupalSettings']['magazineplus']['slideoutInit']['slideoutTouchSwipe'] = false;
}
}
function magazineplus_library_info_build() {
$google_maps_key = theme_get_setting('google_maps_key');
if (!empty($google_maps_key)) {
$google_maps_key_string = '&key='.$google_maps_key;
} else {
$google_maps_key_string = '';
}
$libraries = [];
$libraries['google-maps-dynamic'] = [
'version' => '3',
'remote' => 'https://maps.googleapis.com/maps/api/js',
'js' => [
'https://maps.googleapis.com/maps/api/js?v=3'.$google_maps_key_string => [
'scope' => ['footer'],
],
],
'license' => [
'name' => ['Google Terms of Service'],
'url' => ['https://developers.google.com/maps/terms'],
],
];
return $libraries;
}
/**
* Implements hook_preprocess_HOOK() for node.html.twig.
*/
function magazineplus_preprocess_node(&$variables) {
// Remove the "Add new comment" link on teasers or when the comment form is
// displayed on the page.
if ($variables['teaser'] || !empty($variables['content']['comments']['comment_form'])) {
unset($variables['content']['links']['comment']['#links']['comment-add']);
}
$variables['posted_ago'] = \Drupal::service('date.formatter')
->formatInterval(REQUEST_TIME - $variables['node']
->getCreatedTime(), $granularity = 1);
$node_content = $variables['content'];
$node_content = render($node_content);
$words = str_word_count(strip_tags($node_content));
$minutes = floor($words / 275);
$variables['minutes'] = $minutes;
if (isset($variables['node']->comment)) {
$comment_count = $variables['node']->get('comment')->__get('comment_count');
if ($comment_count) {
$variables['comment_count'] = $comment_count;
} else {
$variables['comment_count'] = "0";
}
}
$variables['mt_setting']['reading_time'] = theme_get_setting('reading_time');
$variables['mt_setting']['share_links'] = theme_get_setting('share_links');
$variables['mt_setting']['print_button'] = theme_get_setting('print_button');
$variables['mt_setting']['share_links_print_position'] = theme_get_setting('share_links_print_position');
$variables['mt_setting']['font_resize'] = theme_get_setting('font_resize');
$variables['mt_setting']['post_progress'] = theme_get_setting('post_progress');
$variables['mt_setting']['affix_side'] = theme_get_setting('affix_side');
}
function magazineplus_preprocess_node__article(&$variables) {
$variables['mt_setting']['reading_time'] = theme_get_setting('reading_time');
// Count the words of article in order to calculate the reading time
$node_content = $variables['content'];
$node_content = render($node_content);
$words = str_word_count(strip_tags($node_content));
if (isset($variables['content']['comment'])) {
$node_comments = $variables['content']['comment'];
$node_comments = render($node_comments);
$words = $words - str_word_count(strip_tags($node_comments));
}
$variables['minutes'] = floor($words / 275);
}
/**
* Implements hook_preprocess_HOOK() for block.html.twig.
*/
function magazineplus_preprocess_block(&$variables) {
// Add a clearfix class to blocks.
$variables['attributes']['class'][] = 'clearfix';
}
/**
* Implements hook_preprocess_HOOK() for field--block-content--mt-google-maps.html.twig.
*/
function magazineplus_preprocess_field__block_content__mt_google_maps(&$variables) {
$variables['#attached']['library'][] = 'magazineplus/google-maps-init';
$variables['field_mt_latitude_value'] = $variables['element']['#object']->get('field_mt_latitude')->first()->getValue()['value'];
$variables['field_mt_longitude_value'] = $variables['element']['#object']->get('field_mt_longitude')->first()->getValue()['value'];
$variables['field_mt_map_zoom_value'] = $variables['element']['#object']->get('field_mt_map_zoom')->first()->getValue()['value'];
}
/**
* Implements hook_preprocess_HOOK() for field--block-content--mt-background-image-block.html.twig.
*/
function magazineplus_preprocess_field__block_content__mt_background_image_block(&$variables) {
$variables['background_image_uri'] = $variables['element']['#object']->get('field_mt_background_image')->first()->entity->getFileUri();
$variables['bg_image_overlay_opacity'] = $variables['element']['#object']->get('field_mt_bg_image_opacity')->first()->getValue()['value']/100;
$variables['bg_image_overlay_color'] = $variables['element']['#object']->get('field_mt_bg_image_color')->first()->getValue()['value'];
$variables['bg_image_layout_mode'] = $variables['element']['#object']->get('field_mt_bg_image_layout_mode')->first()->getValue()['value'];
if (!empty($variables['element']['#object']->get('field_mt_bg_image_positioning')->first()) and $variables['element']['#object']->get('field_mt_bg_image_positioning')->first()->getValue()['value'] == "1") {
$variables['field_mt_bg_image_positioning_value'] = "background-image--attachment-fixed";
} else {
$variables['field_mt_bg_image_positioning_value'] = "background-image--attachment-scroll";
}
}
/**
* Implements hook_preprocess_HOOK() for field--block-content--mt-main-slideshow-block.html.twig.
*/
function magazineplus_preprocess_field__block_content__mt_main_slideshow_block(&$variables) {
$paragraphs = $variables['element']['#items']->referencedEntities();
if (!empty($paragraphs)) {
foreach ($paragraphs as $key => $paragraph) {
$slide_image = $paragraph->toArray()['field_mt_ms_slide_image'];
$slide_caption = $paragraph->toArray()['field_mt_ms_slide_caption'];
$slide_caption_color = $paragraph->toArray()['field_mt_ms_slide_caption_color'];
$slide_caption_opacity = $paragraph->toArray()['field_mt_ms_slide_caption_opac'];
$slide_title = $paragraph->toArray()['field_mt_ms_slide_title'];
$slide_links = $paragraph->toArray()['field_mt_ms_slide_link'];
$slide_image = $paragraph->toArray()['field_mt_ms_slide_image'];
$slide_vimeo_id = $paragraph->toArray()['field_mt_ms_slide_vimeo_id'];
$slide_youtube_id = $paragraph->toArray()['field_mt_ms_slide_youtube_id'];
$slide_video_volume = $paragraph->toArray()['field_mt_ms_slide_volume'];
if (!empty($slide_image[0])) {
$file = File::load($slide_image[0]['target_id']);
$path = $file->getFileUri();
$variables['items'][$key]['slide_image_url'] = $path;
$variables['items'][$key]['slide_image_alt'] = $slide_image[0]['alt'];
} else {
$variables['items'][$key]['slide_image_url'] = "";
$variables['items'][$key]['slide_image_alt'] = "";
}
if (!empty($slide_caption[0])) {
$variables['items'][$key]['slide_caption'] = $slide_caption[0]['value'];
} else {
$variables['items'][$key]['slide_caption'] = false;
}
if (!empty($slide_caption_color[0])) {
$variables['items'][$key]['slide_caption_color'] = $slide_caption_color[0]['value'];
} else {
$variables['items'][$key]['slide_caption_color'] = "region--light-typography region--dark-background";
}
if (!empty($slide_caption_opacity[0])) {
$variables['items'][$key]['slide_caption_opacity'] = $slide_caption_opacity[0]['value']/100;
} else {
$variables['items'][$key]['slide_caption_opacity'] = 0;
}
if (!empty($slide_title[0])) {
$variables['items'][$key]['slide_title'] = $slide_title[0]['value'];
} else {
$variables['items'][$key]['slide_title'] = false;
}
if (!empty($slide_links[0])) {
$variables['items'][$key]['slide_first_link_url'] = Url::fromUri($slide_links[0]['uri']);
$variables['items'][$key]['slide_first_link_title'] = $slide_links[0]['title'];
foreach ($slide_links as $slide_link_key => $slide_link) {
$variables['items'][$key]['slide_links'][$slide_link_key]['slide_link_url'] = Url::fromUri($slide_links[$slide_link_key]['uri']);
$variables['items'][$key]['slide_links'][$slide_link_key]['slide_link_title'] = $slide_links[$slide_link_key]['title'];
}
} else {
$variables['items'][$key]['slide_first_link_url'] = false;
$variables['items'][$key]['slide_first_link_title'] = false;
}
if (!empty($slide_vimeo_id[0])) {
$variables['items'][$key]['slide_vimeo_id'] = $slide_vimeo_id[0]['value'];
} else {
$variables['items'][$key]['slide_vimeo_id'] = false;
}
if (!empty($slide_youtube_id[0])) {
$variables['items'][$key]['slide_youtube_id'] = $slide_youtube_id[0]['value'];
} else {
$variables['items'][$key]['slide_youtube_id'] = false;
}
if (!empty($slide_video_volume[0]) and $slide_video_volume[0]['value'] != 0) {
$variables['items'][$key]['slide_video_volume'] = $slide_video_volume[0]['value'];
} else {
$variables['items'][$key]['slide_video_volume'] = "mute";
}
}
}
if ($variables['element']['#object']->get('field_mt_main_slideshow_layout')->first()->getValue()['value'] == "fullwidth") {
$variables['field_mt_main_slideshow_layout_value'] = "auto";
$variables['field_mt_main_slideshow_autoheight'] = "off";
} else {
$variables['field_mt_main_slideshow_layout_value'] = "fullscreen";
$variables['field_mt_main_slideshow_autoheight'] = "on";
}
if (!empty($variables['element']['#object']->get('field_mt_ms_initial_height')->first())) {
$variables['field_mt_ms_initial_height_value'] = (int) $variables['element']['#object']->get('field_mt_ms_initial_height')->first()->getValue()['value'];
} else {
$variables['field_mt_ms_initial_height_value'] = 650;
}
if (!empty($variables['element']['#object']->get('field_mt_ms_effect')->first())) {
$variables['field_mt_ms_effect_value'] = $variables['element']['#object']->get('field_mt_ms_effect')->first()->getValue()['value'];
} else {
$variables['field_mt_ms_effect_value'] = "fade";
}
if (!empty($variables['element']['#object']->get('field_mt_ms_effect_duration')->first())) {
$variables['field_mt_ms_effect_duration_value'] = (int) $variables['element']['#object']->get('field_mt_ms_effect_duration')->first()->getValue()['value']*1000;
} else {
$variables['field_mt_ms_effect_duration_value'] = 9000;
}
if (!empty($variables['element']['#object']->get('field_mt_ms_touch_swipe_nav')->first()) and $variables['element']['#object']->get('field_mt_ms_touch_swipe_nav')->first()->getValue()['value'] == "1") {
$variables['field_mt_ms_touch_swipe_nav_value'] = "on";
} else {
$variables['field_mt_ms_touch_swipe_nav_value'] = "off";
}
if (!empty($variables['element']['#object']->get('field_mt_ms_ignore_header_height')->first()) and $variables['element']['#object']->get('field_mt_ms_ignore_header_height')->first()->getValue()['value'] == "1") {
$variables['field_mt_ms_ignore_header_height_value'] = ".header-container, .toolbar-tray-horizontal";
} else {
$variables['field_mt_ms_ignore_header_height_value'] = ".toolbar-tray-horizontal";
}
if (!empty($variables['element']['#object']->get('field_mt_ms_navigation_style')->first()) and $variables['element']['#object']->get('field_mt_ms_navigation_style')->first()->getValue()['value'] == "bullets") {
$variables['field_mt_ms_bullets_enable'] = true;
$variables['field_mt_ms_tabs_enable'] = false;
$variables['field_mt_ms_thumbs_enable'] = false;
} elseif (!empty($variables['element']['#object']->get('field_mt_ms_navigation_style')->first()) and $variables['element']['#object']->get('field_mt_ms_navigation_style')->first()->getValue()['value'] == "titles_carousel") {
$variables['field_mt_ms_bullets_enable'] = false;
$variables['field_mt_ms_tabs_enable'] = true;
$variables['field_mt_ms_thumbs_enable'] = false;
} elseif (!empty($variables['element']['#object']->get('field_mt_ms_navigation_style')->first()) and $variables['element']['#object']->get('field_mt_ms_navigation_style')->first()->getValue()['value'] == "vertical_thumbs") {
$variables['field_mt_ms_bullets_enable'] = false;
$variables['field_mt_ms_tabs_enable'] = false;
$variables['field_mt_ms_thumbs_enable'] = true;
} else {
$variables['field_mt_ms_bullets_enable'] = false;
$variables['field_mt_ms_tabs_enable'] = false;
$variables['field_mt_ms_thumbs_enable'] = false;
}
if (!empty($variables['element']['#object']->get('field_mt_ms_bullets_position')->first())) {
$variables['field_mt_ms_bullets_position_value'] = $variables['element']['#object']->get('field_mt_ms_bullets_position')->first()->getValue()['value'];
} else {
$variables['field_mt_ms_bullets_position_value'] = "center";
}
if (!empty($variables['element']['#object']->get('field_mt_ms_background_opacity')->first())) {
$variables['field_mt_ms_background_opacity_value'] = (int) $variables['element']['#object']->get('field_mt_ms_background_opacity')->first()->getValue()['value']/100;
} else {
$variables['field_mt_ms_background_opacity_value'] = 0;
}
}
/**
* Implements hook_preprocess_HOOK() for field--field-mt-video-gallery-slides.html.twig.
*/
function magazineplus_preprocess_field__field_mt_video_gallery_slides(&$variables) {
$paragraphs = $variables['element']['#items']->referencedEntities();
if (!empty($paragraphs)) {
foreach ($paragraphs as $key => $paragraph) {
$vimeo_id = $paragraph->toArray()['field_mt_vgs_vimeo_id'];
$youtube_id = $paragraph->toArray()['field_mt_vgs_youtube_id'];
$volume = $paragraph->toArray()['field_mt_vgs_volume'];
$slide_title = $paragraph->toArray()['field_mt_vgs_slide_title'];
$thumbnail = $paragraph->toArray()['field_mt_vgs_thumbnail'];
if (!empty($vimeo_id[0])) {
$variables['items'][$key]['vimeo_id'] = $vimeo_id[0]['value'];
} else {
$variables['items'][$key]['vimeo_id'] = false;
}
if (!empty($youtube_id[0])) {
$variables['items'][$key]['youtube_id'] = $youtube_id[0]['value'];
} else {
$variables['items'][$key]['youtube_id'] = false;
}
if (!empty($volume[0]) and $volume[0]['value'] != 0) {
$variables['items'][$key]['volume'] = $volume[0]['value'];
} else {
$variables['items'][$key]['volume'] = "mute";
}
if (!empty($slide_title[0])) {
$variables['items'][$key]['slide_title'] = $slide_title[0]['value'];
} else {
$variables['items'][$key]['slide_title'] = false;
}
if (!empty($thumbnail[0])) {
$file = File::load($thumbnail[0]['target_id']);
$path = $file->getFileUri();
$thumb_url = ImageStyle::load('mt_video_gallery_thumbnail')->buildUrl($path);
$main_url = ImageStyle::load('mt_slideshow_boxed')->buildUrl($path);
$variables['items'][$key]['thumbnail_thumb_styled_uri'] = $thumb_url;
$variables['items'][$key]['thumbnail_main_styled_uri'] = $main_url;
$variables['items'][$key]['thumbnail_alt'] = $thumbnail[0]['alt'];
} else {
$variables['items'][$key]['thumbnail_thumb_styled_uri'] = "";
$variables['items'][$key]['thumbnail_main_styled_uri'] = "";
$variables['items'][$key]['thumbnail_alt'] = "";
}
}
}
}
/**
* Implements hook_preprocess_HOOK() for pager.html.twig.
*/
function magazineplus_preprocess_pager(&$variables) {
$variables['#attached']['library'][] = 'magazineplus/pager';
}
/**
* Implements hook_preprocess_HOOK() for views-mini-pager.html.twig.
*/
function magazineplus_preprocess_views_mini_pager(&$variables) {
$variables['#attached']['library'][] = 'magazineplus/mini-pager';
}
/**
* Implements hook_preprocess_HOOK() for menu.html.twig.
*/
function magazineplus_preprocess_menu(&$variables) {
$variables['attributes']['class'][] = 'clearfix';
}
/**
* Implements hook_preprocess_HOOK() for products views.
*/
function magazineplus_preprocess_views_view_unformatted__mt_products(&$variables) {
$variables['#attached']['library'][] = 'magazineplus/view-products-grid';
}
/**
* Implements hook_preprocess_HOOK() for team members grid views.
*/
function magazineplus_preprocess_views_view_unformatted__mt_team_members_grid(&$variables) {
$variables['#attached']['library'][] = 'magazineplus/view-team-members-grid';
}
/**
* Implements hook_preprocess_HOOK() for team members list views.
*/
function magazineplus_preprocess_views_view_unformatted__mt_team_members_list(&$variables) {
$variables['#attached']['library'][] = 'magazineplus/view-titles-list';
}
/**
* Implements hook_preprocess_HOOK() for latest posts views.
*/
function magazineplus_preprocess_views_view_unformatted__mt_latest_posts(&$variables) {
$variables['#attached']['library'][] = 'magazineplus/view-latest-posts';
}
/**
* Implements hook_preprocess_HOOK() for posts masonry views.
*/
function magazineplus_preprocess_views_view_list__mt_posts_masonry(&$variables) {
$variables['#attached']['library'][] = 'magazineplus/view-posts-masonry';
}
/**
* Implements hook_preprocess_HOOK() for videos grid views.
*/
function magazineplus_preprocess_views_view_unformatted__mt_videos_grid(&$variables) {
$variables['#attached']['library'][] = 'magazineplus/view-videos-grid';
}
/**
* Implements hook_preprocess_HOOK() for popular tags views.
*/
function magazineplus_preprocess_views_view_unformatted__mt_popular_tags(&$variables) {
$variables['#attached']['library'][] = 'magazineplus/view-popular-taxonomy';
}
/**
* Implements hook_preprocess_HOOK() for posts grid views.
*/
function magazineplus_preprocess_views_view_unformatted__mt_posts_grid(&$variables) {
$variables['#attached']['library'][] = 'magazineplus/view-posts-grid';
}
/**
* Implements hook_preprocess_HOOK() for posts grid views.
*/
function magazineplus_preprocess_views_view_unformatted__mt_user_posts(&$variables) {
$variables['#attached']['library'][] = 'magazineplus/view-posts-grid';
}
/**
* Implements hook_preprocess_HOOK() for posts carousel views.
*/
function magazineplus_preprocess_views_view_list__mt_posts_carousel(&$variables) {
$variables['#attached']['library'][] = 'magazineplus/owl-carousel-posts-init';
}
/**
* Implements hook_preprocess_HOOK() for square posts slider views.
*/
function magazineplus_preprocess_views_view_list__mt_square_posts_carousel(&$variables) {
$variables['#attached']['library'][] = 'magazineplus/owl-carousel-square-posts-init';
}
/**
* Implements hook_preprocess_HOOK() for posts slider views.
*/
function magazineplus_preprocess_views_view_list__mt_posts_slider(&$variables) {
$variables['#attached']['library'][] = 'magazineplus/owl-carousel-posts-slider-init';
}
/**
* Implements hook_preprocess_HOOK() for full screen slideshow.
*/
function magazineplus_preprocess_views_view_list__mt_slideshow_full_screen__block(&$variables) {
$rows = $variables['rows'];
if (!empty($rows)) {
foreach ($rows as $key => $row) {
$path = $variables['rows'][$key]['content']['#row']->_entity->get('field_mt_slideshow_image')->first()->entity->getFileUri();
$variables['rows'][$key]['slide_thumbnail'] = ImageStyle::load('mt_slideshow_thumbnail')->buildUrl($path);
}
}
$variables['mt_setting']['rs_slideshow_fullscreen_effect'] = theme_get_setting('rs_slideshow_fullscreen_effect');
//Load transparent-header library
$transparent_header_state = theme_get_setting('transparent_header_state');
if ($transparent_header_state) {
$variables['#attached']['library'][] = 'magazineplus/transparent-header';
}
}
/**
* Implements hook_preprocess_HOOK() for boxed width slideshow.
*/
function magazineplus_preprocess_views_view_list__mt_slideshow_boxed_width__block(&$variables) {
$rows = $variables['rows'];
if (!empty($rows)) {
foreach ($rows as $key => $row) {
$path = $variables['rows'][$key]['content']['#row']->_entity->get('field_mt_slideshow_image')->first()->entity->getFileUri();
$variables['rows'][$key]['slide_thumbnail'] = ImageStyle::load('mt_slideshow_thumbnail')->buildUrl($path);
}
}
$variables['mt_setting']['rs_slideshow_boxedwidth_effect'] = theme_get_setting('rs_slideshow_boxedwidth_effect');
}
/**
* Implements hook_preprocess_HOOK() for internal banner slideshow.
*/
function magazineplus_preprocess_views_view_list__mt_internal_banner__block(&$variables) {
$rows = $variables['rows'];
if (!empty($rows)) {
foreach ($rows as $key => $row) {
$path = $variables['rows'][$key]['content']['#row']->_entity->get('field_mt_banner_image')->get($key)->entity->getFileUri();
$variables['rows'][$key]['slide_thumbnail'] = ImageStyle::load('mt_slideshow_thumbnail')->buildUrl($path);
}
}
$variables['mt_setting']['rs_slideshow_internal_effect'] = theme_get_setting('rs_slideshow_internal_effect');
}
/**
* Implements hook_preprocess_HOOK() for testimonials list views.
*/
function magazineplus_preprocess_views_view_unformatted__mt_testimonials(&$variables) {
$variables['#attached']['library'][] = 'magazineplus/view-testimonials-list';
}
/**
* Implements hook_preprocess_HOOK() for testimonials carousel views.
*/
function magazineplus_preprocess_views_view_list__mt_testimonials_carousel(&$variables) {
$variables['#attached']['library'][] = 'magazineplus/owl-carousel-testimonials-init';
}
/**
* Implements hook_preprocess_HOOK() for featured video views.
*/
function magazineplus_preprocess_views_view_unformatted__mt_featured_video(&$variables) {
$variables['#attached']['library'][] = 'magazineplus/view-featured-video';
}
/**
* Implements hook_theme_suggestions_HOOK_alter() for form templates.
*/
function magazineplus_theme_suggestions_form_alter(array &$suggestions, array $variables) {
if ($variables['element']['#form_id'] == 'search_block_form') {
$suggestions[] = 'form__search_block_form';
}
}
/**
* Implements hook_form_alter() to add classes to the search form.
*/
function magazineplus_form_alter(&$form, FormStateInterface $form_state, $form_id) {
if (in_array($form_id, ['search_block_form', 'search_form'])) {
$key = ($form_id == 'search_block_form') ? 'actions' : 'basic';
if (!isset($form[$key]['submit']['#attributes'])) {
$form[$key]['submit']['#attributes'] = new Attribute();
}
$form[$key]['submit']['#attributes']->addClass('search-form__submit');
$form['keys']['#attributes']['placeholder'] = t('Search...');
}
}
function magazineplus_preprocess_field(&$variables) {
$element = $variables['element'];
$variables['view_mode'] = $element['#view_mode']; //Expose node view_mode to field templates
}
function magazineplus_preprocess_field__entity_reference(&$variables) {
$variables['entity_reference_target_type'] = $variables['element']['#items']->getItemDefinition()->getSetting('target_type');
}
function magazineplus_preprocess_field__block_content__mt_tabs_block(&$variables){
$variables['entity_reference_target_type'] = $variables['element']['#items']->getItemDefinition()->getSetting('target_type');
$block_uuid = $variables['element']['#object']->toArray()['uuid'][0]['value'];
$blocks = $variables['element']['#items']->referencedEntities();
if (isset($blocks)) {
foreach ($blocks as $key => $block) {
$variables['items'][$key]['block_data']['label'] = $block->label();
if (!empty($block_uuid)) {
$variables['items'][$key]['block_data']['id'] = Html::getUniqueId($block_uuid."-".$key);
} else {
$variables['items'][$key]['block_data']['id'] = Html::getUniqueId($block->id());
}
}
}
}
function magazineplus_preprocess_field__block_content__mt_collapsible_block(&$variables) {
$block_uuid = $variables['element']['#object']->toArray()['uuid'][0]['value'];
if (!empty($block_uuid)) {
$variables['block_data']['id'] = Html::getUniqueId($block_uuid);
}
if (!empty($variables['element']['#object']->get('field_mt_cb_state')->first()) && $variables['element']['#object']->get('field_mt_cb_state')->first()->getValue()['value'] == "expanded") {
$variables['field_mt_cb_state_value'] = "in";
$variables['field_mt_cb_trigger_state_value'] = "";
} else {
$variables['field_mt_cb_state_value'] = "";
$variables['field_mt_cb_trigger_state_value'] = "collapsed";
}
if (!empty($variables['element']['#object']->get('field_mt_cb_title')->first())) {
$variables['field_mt_cb_title_value'] = $variables['element']['#object']->get('field_mt_cb_title')->first()->getValue()['value'];
} else {
$variables['field_mt_cb_title_value'] = "";
}
if (!empty($variables['element']['#object']->get('field_mt_cb_trigger_position')->first())) {
$variables['field_mt_cb_trigger_position_value'] = $variables['element']['#object']->get('field_mt_cb_trigger_position')->first()->getValue()['value'];
} else {
$variables['field_mt_cb_trigger_position_value'] = "";
}
if (!empty($variables['element']['#object']->get('field_mt_cb_expand_icon')->first())) {
$variables['field_mt_cb_expand_icon_value'] = $variables['element']['#object']->get('field_mt_cb_expand_icon')->first()->getValue()['value'];
} else {
$variables['field_mt_cb_expand_icon_value'] = "";
}
if (!empty($variables['element']['#object']->get('field_mt_cb_collapse_icon')->first())) {
$variables['field_mt_cb_collapse_icon_value'] = $variables['element']['#object']->get('field_mt_cb_collapse_icon')->first()->getValue()['value'];
} else {
$variables['field_mt_cb_collapse_icon_value'] = "";
}
}
function magazineplus_preprocess_field__block_content__mt_media_tabs_block(&$variables){
$current_language_id = \Drupal::languageManager()->getCurrentLanguage()->getId();
$variables['entity_reference_target_type'] = $variables['element']['#items']->getItemDefinition()->getSetting('target_type');
$paragraph_uuid = $variables['element']['#object']->toArray()['uuid'][0]['value'];
$paragraphs = $variables['element']['#items']->referencedEntities();
if (isset($paragraphs)) {
foreach ($paragraphs as $key => $paragraph_item) {
if (!empty($paragraph_uuid)) {
$variables['items'][$key]['tab_item_data']['id'] = Html::getUniqueId($paragraph_uuid."-".$key);
} else {
$variables['items'][$key]['tab_item_data']['id'] = Html::getUniqueId($paragraph_item->id());
}
if ($paragraph_item->hasTranslation($current_language_id)) {
$video_field = $paragraph_item->getTranslation($current_language_id)->get('field_mt_media_video')->view();
$media_image = $paragraph_item->getTranslation($current_language_id)->toArray()['field_mt_media_image'];
} else {
$media_image = $paragraph_item->toArray()['field_mt_media_image'];
$video_field = $paragraph_item->get('field_mt_media_video')->view();
}
if (!empty($media_image[0])) {
$file = File::load($media_image[0]['target_id']);
$path = $file->getFileUri();
$thumb_url = ImageStyle::load('mt_media_tab_image')->buildUrl($path);
$variables['items'][$key]['media_image_styled_url'] = $thumb_url;
} else {
$variables['items'][$key]['media_image_styled_url'] = "";
}
//get the video field from paragraph and generate render array with view()
$video_field['#label_display'] = 'hidden'; //Hide the field label
$video_field[0]['children']['#query']['autoplay'] = 0; //Set autoplay to false
$variables['items'][$key]['video_field'] = $video_field;
}
}
}
function magazineplus_theme_suggestions_image_formatter_alter(array &$suggestions, array $variables) {
$entity = $variables['item']->getEntity();
$field_name = $variables['item']->getParent()->getName();
if (isset($entity) && isset($field_name)) {
$suggestions[] = 'image_formatter__' . $entity->getEntityTypeId() . '__' . $field_name;
$suggestions[] = 'image_formatter__' . $entity->getEntityTypeId() . '__' . $entity->bundle() . '__' . $field_name;
}
}