You are here

function themekey_node_get_simple_node_property in ThemeKey 7.3

Same name and namespace in other branches
  1. 6.4 modules/themekey.node.inc \themekey_node_get_simple_node_property()
  2. 6.2 modules/themekey.node.inc \themekey_node_get_simple_node_property()
  3. 6.3 modules/themekey.node.inc \themekey_node_get_simple_node_property()
  4. 7 modules/themekey.node.inc \themekey_node_get_simple_node_property()
  5. 7.2 modules/themekey.node.inc \themekey_node_get_simple_node_property()

Helper function that loads a node and returns the value of a node's property.

Parameters

$nid: a node id

$property: name of a node's attribute as string

Return value

the value of the property or NULL

11 calls to themekey_node_get_simple_node_property()
themekey_blog_nid2uid in modules/themekey.blog.inc
ThemeKey mapping function to set a ThemeKey property's value (destination) with the aid of another ThemeKey property (source).
themekey_node_nid2changed in modules/themekey.node.inc
ThemeKey mapping function to set a ThemeKey property's value (destination) with the aid of another ThemeKey property (source).
themekey_node_nid2created in modules/themekey.node.inc
ThemeKey mapping function to set a ThemeKey property's value (destination) with the aid of another ThemeKey property (source).
themekey_node_nid2language in modules/themekey.node.inc
ThemeKey mapping function to set a ThemeKey property's value (destination) with the aid of another ThemeKey property (source).
themekey_node_nid2promote in modules/themekey.node.inc
ThemeKey mapping function to set a ThemeKey property's value (destination) with the aid of another ThemeKey property (source).

... See full list

1 string reference to 'themekey_node_get_simple_node_property'
themekey_ui_nid2theme in ./themekey_ui.module
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.

File

modules/themekey.node.inc, line 257
Provides some node attributes as ThemeKey properties.

Code

function themekey_node_get_simple_node_property($nid, $property) {
  static $nodes = array();
  if (!isset($nodes[$nid])) {

    //node_load() must not be called from hook_init(). Therefore, we have to execute SQL here
    $nodes[$nid] = db_select('node', 'n')
      ->fields('n')
      ->condition('n.nid', $nid)
      ->execute()
      ->fetchObject();
  }
  if (isset($nodes[$nid]->{$property})) {
    return $nodes[$nid]->{$property};
  }
  return NULL;
}