You are here

function themekey_node_nid2field_value in ThemeKey 7.3

ThemeKey mapping function to set a ThemeKey property's value (destination) with the aid of another ThemeKey property (source).

src: node:nid dst: node:field_...

Parameters

$nid: a node id

$args: array, keys required:

  • 'field_name'
  • 'column'

Return value

string or NULL if no value could be mapped

1 string reference to 'themekey_node_nid2field_value'
themekey_node_themekey_properties in modules/themekey.node.inc
Implements hook_themekey_properties().

File

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

Code

function themekey_node_nid2field_value($nid, $args) {
  $values = array();
  $query = new ThemeKeyEntityFieldQuery();
  $query
    ->entityCondition('entity_type', 'node')
    ->propertyCondition('nid', $nid)
    ->fieldCondition($args['field_name'], $args['column'], '', '<>');
  if ($query
    ->execute() && !empty($query->orderedResults)) {
    foreach ($query->orderedResults as $result) {
      $values[] = (string) $result->{$args['field_name']};
    }
  }
  return count($values) ? $values : NULL;
}