You are here

function vartheme_preprocess_page in Varbase: The Ultimate Drupal CMS Starter Kit (Bootstrap Ready) 7.3

Implements hook_preprocess_page().

See also

page.tpl.php

File

themes/vartheme/templates/system/page.vars.php, line 12
page.vars.php

Code

function vartheme_preprocess_page(&$variables) {

  /* Ensure that important region are printed even if they are empty,
   * they have wrappers that impact the theme drastically.
   */
  foreach (array(
    'footer',
    'navigation',
    'header',
    'content_top',
  ) as $name) {
    if (isset($variables['page'][$name]) && !$variables['page'][$name]) {
      $variables['page'][$name]['#theme_wrappers'] = array(
        'region',
      );
      $variables['page'][$name]['#region'] = $name;
    }
  }
  $variables['navbar_classes_array'] = array_diff($variables['navbar_classes_array'], array(
    'container',
  ));

  // check if this is a panel page
  if ($panel_page = page_manager_get_current_page()) {

    // add a generic suggestion for all panel pages
    $variables['theme_hook_suggestions'][] = 'page__panel';
    $variables['theme_hook_suggestions'][] = 'page__panel__' . $panel_page['name'];

    // get current display and layout
    $panel_display = panels_get_current_page_display();
    if (isset($panel_display) && !empty($panel_display->layout)) {
      $variables['theme_hook_suggestions'][] = 'page__panel__' . $panel_display->layout;
    }
  }

  // Add information about the number of sidebars.
  $variables['container'] = 'container';
  $variables['content_column_class_array'] = array(
    'col-sm-12',
  );
  $variables['sidebar_first_column_class_array'] = array(
    'col-sm-3',
    'flip',
  );
  $variables['sidebar_second_column_class_array'] = array(
    'col-sm-3',
    'flip',
  );
  if (!empty($variables['page']['sidebar_first']) && !empty($variables['page']['sidebar_second'])) {
    $variables['content_column_class_array'] = array(
      'col-sm-6',
      'flip',
      'col-md-push-3',
    );
    $variables['sidebar_first_column_class_array'][] = 'col-md-pull-6';
  }
  elseif (!empty($variables['page']['sidebar_first'])) {
    $variables['content_column_class_array'] = array(
      'col-sm-9',
      'flip',
      'col-md-push-3',
    );
    $variables['sidebar_first_column_class_array'][] = 'col-md-pull-9';
  }
  elseif (!empty($variables['page']['sidebar_second'])) {
    $variables['content_column_class_array'] = array(
      'col-sm-9',
      'flip',
    );
  }
  else {
    if ($panel_page = page_manager_get_current_page()) {
      $variables['container'] = 'container-fluid';
    }
  }
}