You are here

function og_context_preprocess_html in Organic groups 7.2

Same name and namespace in other branches
  1. 7 og_context/og_context.module \og_context_preprocess_html()

Implement hook_preprocess_html().

HTML preprocess; Add context related templates and CSS.

File

og_context/og_context.module, line 90
Get a group from a viewed page.

Code

function og_context_preprocess_html(&$variables) {
  if ($context = og_context()) {

    // Add template suggestions.
    $variables['theme_hook_suggestions'][] = 'page__og_context';
    $variables['theme_hook_suggestions'][] = 'page__og_context__' . $context['group_type'];
    $variables['theme_hook_suggestions'][] = 'page__og_context__' . $context['group_type'] . '__' . $context['gid'];

    // Add CSS.
    $clean_html = drupal_html_class('og-context-' . $context['group_type']);
    $variables['classes_array'][] = 'og-context';
    $variables['classes_array'][] = $clean_html;
    $variables['classes_array'][] = $clean_html . '-' . $context['gid'];

    // Add context to JS.
    og_context_add_js($context);
  }
}