You are here

function themekey_ui_node_author2theme in ThemeKey 7.3

This function implements the interface of a ThemeKey mapping function but doesn't set a ThemeKey property's value. It sets the Drupal static themekey_custom_theme which will cause ThemeKey to use this theme.

Parameters

$nid: a node id, current value of ThemeKey property node:nid

Return value

string "static" if global custom theme has been set or NULL if no theme has been assigned to the node

1 string reference to 'themekey_ui_node_author2theme'
themekey_ui_themekey_properties in ./themekey_ui.module
Implements hook_themekey_properties().

File

./themekey_ui.module, line 124
ThemeKey UI is an extension for ThemeKey

Code

function themekey_ui_node_author2theme($nid) {
  $custom_theme =& drupal_static('themekey_custom_theme', '');

  // node_load() must not be called from hook_init().
  // Therefore, we have to execute SQL here.
  $query = db_select('node', 'n')
    ->fields('tuat', array(
    'theme',
  ))
    ->condition('n.nid', $nid);
  $query
    ->join('themekey_ui_author_theme', 'tuat', 'n.uid = tuat.uid');
  if ($theme = $query
    ->execute()
    ->fetchField()) {
    if ('default' != $theme && themekey_check_theme_enabled($theme)) {
      $custom_theme = $theme;
      return 'static';
    }
  }
  return NULL;
}