You are here

function openlayers_cck_feeds_set_target in Openlayers 6

Same name and namespace in other branches
  1. 6.2 modules/openlayers_cck/includes/openlayers_cck.feeds.inc \openlayers_cck_feeds_set_target()

Set Feeds Target

Callback for mapping. Here we map feeds data to the actual field of the node.

1 string reference to 'openlayers_cck_feeds_set_target'
openlayers_cck_feeds_node_processor_targets_alter in modules/openlayers_cck/includes/openlayers_cck.feeds.inc
Implementation of feeds_node_processor_targets_alter().

File

modules/openlayers_cck/includes/openlayers_cck.feeds.inc, line 41
This file holds the Feeds module integration with the OpenLayers CCK module.

Code

function openlayers_cck_feeds_set_target(&$node, $target, $value) {

  // The field name is the target
  $field_name = $target;

  // Load the field from the node
  $field = isset($node->{$field_name}) ? $node->{$field_name} : array();

  // Handle multiple value fields.
  if (is_array($value)) {
    $i = 0;
    foreach ($value as $v) {
      if (!is_array($v) && !is_object($v)) {
        $field[$i]['openlayers_wkt'] = $v;
      }
      $i++;
    }
  }
  else {
    $field[0]['openlayers_wkt'] = $value;
  }
  $node->{$field_name} = $field;
}