Posted by ronald_istos on May 22, 2011 at 6:55pm
4 followers
| Project: | Feeds |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs review |
Issue Summary
Trying to import multiple links - each one as a separate column in a CSV file and Link mapper (link.inc) can't handle it.
Problem seems to be line 71
$i = 0;
foreach ($value as $v) {
if ($v instanceof FeedsEnclosure) {
$v = $v->getValue();
}
if (!isset($field_data[$i])) {
$field_data[$i] = $defaults[$node->type][$field_name];
}
if ($sub_field != 'url' || (($v = link_cleanup_url($v)) && valid_url($v, true))) {
$field_data[$i][$sub_field] = $v;
}
$i++;
}
$node->$field_name = $field_data;It essentially means that once a second link is encountered and the code above runs again (with $i = 0) the old link gets deleted so only one ever gets stored.
Solution could be to set
$i = count($field_data);This way we take into account existing links in the data array.
Sorry no patch - doing this in a rush!
Comments
#1
http://drupal.org/project/feeds_tamper makes this work by exploding a comma separated list of links into multiple links.
#2
Possible patch for link handling; similar to what is going on for other fields over at #982150: Multiple mappings to the same target.
Give it a try, see how it works for you. To use this title mappings MUST be DIRECTLY AFTER the url field they belong to.
/Robin
#3
#1: Using feeds_tamper is a great advice, thx!
This works well for the URL and the TITLE in parallel, and imports correctly a list of URLs, each with its corresponding title.
#6
Glad to hear it's working good for others too ^.^