You are here

function og_theme_custom_theme in Organic groups theme 7.2

Same name and namespace in other branches
  1. 7 og_theme.module \og_theme_custom_theme()

Implements hook_custom_theme().

Change the theme, based on a group context.

File

./og_theme.module, line 54
Associate theme to a group.

Code

function og_theme_custom_theme() {
  if ($context = og_context()) {

    // Load the group.
    $wrapper = entity_metadata_wrapper($context['group_type'], $context['gid']);

    // Check if a theme field exists, and it isn't defined as "default"
    // (i.e. use the default site theme).
    if (!empty($wrapper->{OG_THEME_FIELD}) && $wrapper->{OG_THEME_FIELD}
      ->value() != '__default') {
      return $wrapper->{OG_THEME_FIELD}
        ->value();
    }
  }
}