Common Tasks

Last updated on
31 May 2017

Drupal 7 will no longer be supported after January 5, 2025. Learn more and find resources for Drupal 7 sites

This page is geared at common support issues in the issue queue. Use anchor tags so individual references can be linked to.

Index

Use other field as an unique target in Feeds 7.x-2.x

By default, you can only choose a few targets as unique target (such as GUID, URL or node title). But Feeds has a (hidden) feature which allows you to choose any target as an unique target.

When to use this feature

Why should one want to use a different field as unique target, you may ask? Well, the GUID field only has a value for items that are imported by Feeds, thus manually created nodes (or other entities) don't have a GUID. The node title might as well not be unique in your case. So, basically you want to use a different field as unique target if you want to update items that are not created by Feeds. An other possible use case is if you use multiple importers for the same content type, as Feeds considers the GUID to be only unique per importer and not unique in general (this does not count for the entity reference mapper, by the way).

Steps

  1. Download Feeds 7.x-2.0-beta1 or later, or apply the patch from #661606-195: Support unique targets in mappers to Feeds.
  2. Create a Feeds importer.
  3. In the processor settings, select "Update existing". In case of the node processor, this option is called "Update existing nodes".
  4. You then have two options:
    • Field validation module
      1. Install the Field validation module.
        Use at least the 7.x-2.5 release or apply the patch from #1705386-18: Feeds integration (Field validation).
      2. Go to "Manage fields" page of your content type.
      3. Click on "validate" for the field you want to be the unique identifier.
      4. Add a validation rule of type "Unique values".
      5. Go to the mapping settings of your Feeds importer, add the field you want to be unique and set this field as an unique target.
    • Own solution
      1. Implement hook_feeds_processor_targets_alter() in a custom module.
      2. For the target you want to make unique, set optional_unique to TRUE.
      3. Also, for the same target, specify a callback function that looks up the node using the unique identifier in unique_callbacks.
      4. Implement the callback function.
      5. Go to the mapping settings of your Feeds importer, add the field you want to be unique and set this field as an unique target.

      See feeds.api.php for further information and examples. Look specific to the examples for hook_feeds_processor_targets_alter() and for my_module_mapper_unique.

  5. Import.

Note: there is also the Unique field module, but at the time of writing, this module doesn't support the unique target feature in Feeds yet.

Import source URL as feed item field.

  1. Download Link module and enable.
  2. Navigate to "Feeds importers" in the Administration menu (admin/structure/feeds).
  3. Edit specific feed.
  4. Select "Mapping for Node Processor"
  5. Create new source: "Item URL (link)"
  6. Select new target: "Link URL"
  7. Select "Add"

Done! The source URL specific to each new feed item will import into the appropriate feed in each node.

Help improve this page

Page status: No known problems

You can: