You are here

function template_preprocess_footermap in footermap: a footer site map 7

Same name and namespace in other branches
  1. 8 footermap.theme.inc \template_preprocess_footermap()

Footermap template preprocess function.

Parameters

&$variables:

File

./footermap.theme.inc, line 12

Code

function template_preprocess_footermap(&$variables) {
  global $user;
  global $language;
  drupal_add_css(drupal_get_path('module', 'footermap') . '/footermap.css', array(
    'type' => 'file',
    'every_page' => TRUE,
    'group' => CSS_DEFAULT,
  ));

  // Bail early if we have cached the footermap.
  if ($variables['cached']) {
    return;
  }

  // We need to remove any menu item that does not match LANGUAGE_NONE or our language.
  $lang = !empty($user->language) ? $user->language : (!empty($language->language) ? $language->language : LANGUAGE_NONE);
  foreach ($variables['footermap'] as $name => $header) {
    if (!empty($header['#items'])) {
      foreach ($header['#items'] as $key => $item) {
        if ($item['#language'] != $lang && $item['#language'] != LANGUAGE_NONE) {
          unset($variables['footermap'][$name]['#items'][$key]);
        }
      }
    }
  }

  // set cache for language
  cache_set('footermap-' . $lang, $variables['footermap'], 'cache', CACHE_TEMPORARY);
}