You are here

function template_preprocess_flippy in Glazed Theme Helper 8

Implements template_preprocess_hook()

File

./glazed_helper.module, line 112
Module file for glazed_helper.

Code

function template_preprocess_flippy(&$vars) {

  // for getting node type
  if ($node = \Drupal::request()->attributes
    ->get('node')) {
    $vars['node'] = $node;
  }
  $prev_label_markup = '<span class="glazed-icon">' . theme_get_setting('previous_svg') . '</span><span class="nextprev-text">' . t(theme_get_setting('previous_label')) . '</span>';
  $next_label_markup = '<span class="nextprev-text">' . t(theme_get_setting('next_label')) . '</span><span class="glazed-icon">' . theme_get_setting('next_svg') . '</span>';
  $prev_label = \Drupal\Core\Render\Markup::create($prev_label_markup);
  $next_label = \Drupal\Core\Render\Markup::create($next_label_markup);

  // Build the variables for twig
  if ($nav = $vars['list']) {
    if (isset($nav['prev']) && $nav['prev']['nid'] != FALSE) {
      $vars['prev'] = \Drupal::service('flippy.pager')
        ->flippy_generate_link($nav['prev']['nid'], $prev_label);
    }
    if (isset($nav['next']) && $nav['next']['nid'] != FALSE) {
      $vars['next'] = \Drupal::service('flippy.pager')
        ->flippy_generate_link($nav['next']['nid'], $next_label);
    }
  }
  unset($vars['list']);
}