You are here

function skinr_context_skinr_preprocess_alter in Skinr 7.2

Same name and namespace in other branches
  1. 8.2 skinr_context/skinr_context.module \skinr_context_skinr_preprocess_alter()

Implements hook_skinr_preprocess_alter().

File

skinr_context/skinr_context.module, line 708
Provides Skinr integration with Context.

Code

function skinr_context_skinr_preprocess_alter(&$skins, $context) {
  $contexts = context_active_contexts();
  foreach ($skins as $key => $skin) {
    if (!empty($skin->gid) && ($group = skinr_context_group_load($skin->gid))) {

      // Remove skins for groups that arent in the right context.
      if (!isset($contexts['skinr_group__' . $skin->gid])) {
        unset($skins[$key]);
      }

      // Set group based weight on skins.
      $skin->weight = $group->weight;
    }
  }

  // Reorder by weight.
  uasort($skins, 'skinr_context_sort_weight');
}