You are here

function themekey_ui_nid2theme in ThemeKey 7.3

Same name and namespace in other branches
  1. 6.4 themekey_ui.module \themekey_ui_nid2theme()
  2. 6.2 themekey_ui.module \themekey_ui_nid2theme()
  3. 6.3 themekey_ui.module \themekey_ui_nid2theme()
  4. 7 themekey_ui.module \themekey_ui_nid2theme()
  5. 7.2 themekey_ui.module \themekey_ui_nid2theme()

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_nid2theme'
themekey_ui_themekey_properties in ./themekey_ui.module
Implements hook_themekey_properties().

File

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

Code

function themekey_ui_nid2theme($nid) {
  $custom_theme =& drupal_static('themekey_custom_theme', '');
  if (!function_exists('themekey_node_get_simple_node_property')) {
    require_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'themekey') . '/modules/themekey.node.inc';
  }

  // node_load() must not be called from hook_init().
  // Therefore, we have to execute SQL here using hook_nodeapi().
  $node = new stdClass();
  $node->nid = $nid;
  $node->vid = themekey_node_get_simple_node_property($nid, 'vid');
  $node->type = themekey_node_get_simple_node_property($nid, 'type');
  themekey_ui_node_load(array(
    $node->nid => $node,
  ), array(
    $node->type,
  ));
  if (!empty($node->themekey_ui_theme) && 'default' != $node->themekey_ui_theme && themekey_check_theme_enabled($node->themekey_ui_theme)) {
    $custom_theme = $node->themekey_ui_theme;
    return 'static';
  }
  return NULL;
}