Active
Project:
Video Filter Field
Version:
7.x-1.1
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
25 Jan 2012 at 23:32 UTC
Updated:
5 Jun 2012 at 21:27 UTC
Adding the following to the module will expose it to feeds mapper so videos can be imported directly:
function video_filter_field_feeds_processor_targets_alter(&$targets, $entity_type, $bundle_name) {
foreach (field_info_instances($entity_type, $bundle_name) as $name => $instance) {
$info = field_info_field($name);
if ($info['type'] == 'video_filter') {
if (array_key_exists('url', $info['columns'])) {
$targets[$name . ':url'] = array(
'name' => t('@name URL', array('@name' => $instance['label'])),
'callback' => 'link_feeds_set_target',
'description' => t('The @label field of the node.', array('@label' => $instance['label'])),
);
}
}
}
}
function video_filter_field_feeds_set_target($source, $entity, $target, $value) {
if (empty($value)) {
return;
}
// Handle non-multiple value fields.
if (!is_array($value)) {
$value = array($value);
}
// Iterate over all values.
$i = 0;
$info = field_info_field($target);
list($field_name, $sub_field) = explode(':', $target);
foreach ($value as $v) {
if (!is_array($v) && !is_object($v)) {
if (strstr($target, 'url')) {
$field['und'][$i]['url'] = $v;
}
}
if ($info['cardinality'] == 1) {
break;
}
$i++;
}
$entity->{$field_name} = $field;
}
Comments
Comment #1
davidcsonka commentedDo you know if it would be possible to expose the field to the Rules framework also?
Comment #2
7wonders commentedYes, it can be done through entity api - http://drupal.org/node/878880
Comment #3
davidcsonka commentedThat's encouraging!
I guess I'll have to figure out how to do that, lol
Comment #4
spanac commented@7wonders: Thank you