You are here

function hook_feeds_processor_targets_alter in Feeds 8.2

Same name and namespace in other branches
  1. 7.2 feeds.api.php \hook_feeds_processor_targets_alter()
  2. 7 feeds.api.php \hook_feeds_processor_targets_alter()

Alter mapping targets for entities. Use this hook to add additional target options to the mapping form of Node processors.

If the key in $targets[] does not correspond to the actual key on the node object ($node->key), real_target MUST be specified. See mappers/link.inc

For an example implementation, see mappers/content.inc

Parameters

&$targets: Array containing the targets to be offered to the user. Add to this array to expose additional options. Remove from this array to suppress options. Remove with caution.

$entity_type: The entity type of the target, for instance a 'node' entity.

$bundle_name: The bundle name for which to alter targets.

Related topics

8 functions implement hook_feeds_processor_targets_alter()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

datetime_feeds_processor_targets_alter in mappers/datetime.inc
Implements hook_feeds_processor_targets_alter().
feeds_tests_feeds_processor_targets_alter in tests/feeds_tests.module
Implements hook_feeds_processor_targets_alter().
file_feeds_processor_targets_alter in mappers/file.inc
Implements hook_feeds_processor_targets_alter().
link_feeds_processor_targets_alter in mappers/link.inc
Implements hook_feeds_processor_targets_alter().
number_feeds_processor_targets_alter in mappers/number.inc
Implements hook_feeds_processor_targets_alter().

... See full list

3 invocations of hook_feeds_processor_targets_alter()
FeedsNodeProcessor::getMappingTargets in lib/Drupal/feeds/Plugin/feeds/processor/FeedsNodeProcessor.php
Return available mapping targets.
FeedsTermProcessor::getMappingTargets in lib/Drupal/feeds/Plugin/feeds/processor/FeedsTermProcessor.php
Return available mapping targets.
FeedsUserProcessor::getMappingTargets in lib/Drupal/feeds/Plugin/feeds/processor/FeedsUserProcessor.php
Return available mapping targets.

File

./feeds.api.php, line 270
Documentation of Feeds hooks.

Code

function hook_feeds_processor_targets_alter(&$targets, $entity_type, $bundle_name) {
  if ($entity_type == 'node') {
    $targets['my_node_field'] = array(
      'name' => t('My custom node field'),
      'description' => t('Description of what my custom node field does.'),
      'callback' => 'my_module_set_target',
      // Specify both summary_callback and form_callback to add a per mapping
      // configuration form.
      'summary_callback' => 'my_module_summary_callback',
      'form_callback' => 'my_module_form_callback',
    );
    $targets['my_node_field2'] = array(
      'name' => t('My Second custom node field'),
      'description' => t('Description of what my second custom node field does.'),
      'callback' => 'my_module_set_target2',
      'real_target' => 'my_node_field_two',
    );
  }
}