You are here

socialblue.theme in Open Social 8.8

The primary PHP file for the Social Blue theme.

File

themes/socialblue/socialblue.theme
View source
<?php

/**
 * @file
 * The primary PHP file for the Social Blue theme.
 */

/**
 * Implements theme_preprocess().
 */
function socialblue_preprocess(&$variables, $hook, $info) {

  // Add style variable to be able to attach new libraries and change templates.
  $style = theme_get_setting('style');
  if (!empty($style)) {
    $variables['style'] = $style;
  }
}

/**
 * Implements hook_library_info_alter().
 */
function socialblue_library_info_alter(&$libraries, $extension) {

  // Add extra CSS files if specific style is chosen.
  $style = theme_get_setting('style');
  if (!empty($style) && $extension === 'socialblue') {
    $theme_path = drupal_get_path('theme', $extension);
    $base_path = 'assets/css/';
    foreach ($libraries as $key => $library) {
      $style_css = $base_path . $key . '--' . $style . '.css';
      if (file_exists($theme_path . '/' . $style_css)) {
        $libraries[$key]['css']['theme'][$style_css] = [];
        $libraries[$key]['css']['theme'][$style_css]['weight'] = 600;
      }
    }

    // Add extra JS for secondary navigation in Sky style.
    if ($style === 'sky') {
      $libraries['navbar']['js']['assets/js/navbar-secondary--sky.min.js'] = [];
    }
  }
}

/**
 * Prepares variables for group templates.
 */
function socialblue_preprocess_group(array &$variables) {
  $view_modes = [
    'teaser',
    'featured',
  ];
  $social_group_types = [
    'open_group',
    'closed_group',
    'public_group',
    'secret_group',
    'flexible_group',
  ];
  if (theme_get_setting('style') === 'sky' && in_array($variables['view_mode'], $view_modes) && in_array($variables['group_type_id'], $social_group_types)) {
    $variables['title_prefix']['teaser_tag'] = [
      '#type' => 'inline_template',
      '#template' => '<div class="teaser__tag">{{ teaser_tag }}</div>',
      '#context' => [
        'teaser_tag' => t('Group'),
      ],
    ];
  }
}

Functions

Namesort descending Description
socialblue_library_info_alter Implements hook_library_info_alter().
socialblue_preprocess Implements theme_preprocess().
socialblue_preprocess_group Prepares variables for group templates.