Closed (fixed)
Project:
FeedAPI
Version:
5.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Reporter:
Created:
7 Aug 2007 at 22:34 UTC
Updated:
17 Jun 2010 at 12:08 UTC
Jump to comment: Most recent file
1) Follow the [Set up field mapping] link on your feed node edit
form.
2) FeedAPI analyzes feed, offers feed item elements as nested collapsible
fieldsets
3) FeedAPI analyzes target content type, offers
- drupal fields (user, title, body, created...)
- CCK fields
as a drop down select box per feed item element.
4) User picks'n'submits
5) FeedAPI stores mapping table per feed and applies it whenever new
feed-items are being downloaded. On this stage there will be some
error reporting necessary.
| Comment | File | Size | Author |
|---|---|---|---|
| #23 | feedapi_mapper-may_cache.patch | 708 bytes | john morahan |
| #19 | hook_feedapi_mapper.patch | 10.36 KB | alex_b |
Comments
Comment #1
boris mann commentedYes, this is it.
But, per feed? What if you have mixed feed items? This is one of those cases where you might need to do global mappings, with per feed overrides.
Comment #2
ericgundersen commentedIf we were to do global mappings should we have a selection of preset CCK types to capture common tags in a designated CCk field, like one for:
- RSS 2.0
- Atom
- itunes
That way we can meet a high percentage of common needs for the average user and keep the override hidden but still there to make space for custom tags as these become more popular?
Or do you see more options needed? for example like Open Media Profile for Open Search with their custom tags in atom ect. or Yahoo weather with parameters and custom tags?
I am having a hard time finding numbers on what % of RSS feeds have custom tags. Would it help if we took one of our managing news systems that we use for load testing and try to diff say 500 feeds to see what the % breakdown is?
Comment #3
alex_b commentedboris, you're right. I was only having feed-specific fields in mind. Of course you will want to define things like "author value should always go into By - CCK field" on a global level.
Comment #4
aron novakIMHO this feature is about a new (advanced) processor which handles these stuff. I cannot see any thing that prevents this. Unfortunately I don't have time for implementing this before SoC deadline.
Comment #5
netlynx commentedI believe key is to ensure 'generic' feed AND fully generic mapping capability.
So if global 'preset' types are incorporated they should be as a nicety and 'overidable' for non-standard uses; with no exceptions (is that what you said?!).
This should not detract from the ability to map other generic feed types as required (ie not RSS/Atom/) such as csv etc.
I was thinking that to prove the concept (and create an early working example) we could simplify the above by implementing the function first, rather than the UI. In other words prototype it.
e.g.
1) Create test case target template (using target node type created using CCK + custom fields)
2) Use some other mechanism to get the mapping data into the DB (I thought of a dummy nodetype with cck fields and user input values but maybe there is another way? - just thinking aloud here. What we need is a referencable map of e.g. title node_title, foo bar
3) Create Element_Mapper FeedAPI item processor
(I'm not sure that the FeedAPI hooks give us enough granularity. It looks like we get a string but not sure yet. Can we have the elements in a key'd array?)
Process item elements array and output to Target(template)nodetype.cck_custom_fields according to stored map
4) Display using Views
I am winging it; not having used any of these modules but I have a strong driver for this and just thought I would put my thoughts in and see what comes back. The idea being that we can implement via incremental prototype rather than trying to launch with the ideal; but always with the ideal in sight.
This is on the basis that I understand the FeedAPI 'should' be able to take ANY input url (i.e. is a 'generic' feedAPI) given a processor to deal with the format. I have not seen any documented constraints on this idea; except my worry about the availability of item elements to processors with current hooks (as per http://groups.drupal.org/node/5301)
Comment #6
netlynx commentedhttp://drupal.org/node/162922
Comment #7
netlynx commented(oops - changing title back)
Comment #8
alex_b commentedAron, how could a processor parse a feed on the feed settings stage to analyze the items the feed contains? Is there a function for it?
Comment #9
buddaFrom what I can remember (back in 4.7) the Node_import module had a nice system for mapping CSV data to flexinode/CCK content-types.
Could any of that be re-used to speed up prototyping?
Comment #10
aron novakFeed Element Mapper can be the killer feature for FeedAPI. :)
Currently it's likely that FeedAPI'll be altered a little bit, I think it's better to wait until this issue ticket become fixed: http://drupal.org/node/178319
Comment #11
alex_b commentedWorking on this. There is a first version in my sandbox: mapping for taxonomy, mappings on a per feed basis.
Comment #12
alex_b commentedA screen cast of the feed element mapper went up on the Development Seed blog today: http://www.developmentseed.org/blog/2007/oct/30/pick-it-feed-stick-it-node
Status quo of the sandbox version (http://cvs.drupal.org/viewvc.py/drupal/contributions/sandbox/alex_b/feed...) is:
* Currently, mapping to taxonomy is fully functional.
* I have not tested this module extensively.
This is the concept:
Defining the map: feedapi_mapper_map_form()
* When loading the feed's map form, FEMP scans the node type specified as feed item node type for fields on the top level
* For each field it calls a feedapi_mapper_map_[field_name] function with the argument 'list'
* The function returns the sub fields it exposes (see feedapi_mapper_map_taxonomy())
* FEMP parses the feed and merges all feed items on it into one feed item, scans the feed item and returns a list of all paths to all elements of the feed item (see _feedapi_mapper_get_feed_elements())
* FEMP uses the return values of all feedapi_mapper_map_[field_name] to build the form elements.
* Each form element is assigned a drop down of all feed elements in feed items found.
* When user submits form, the mapping is being stored with the feed's node id as key.
Mapping: feedapi_nodeapi()
* When a feed item is being processed and a mapping for its feed node exists, the mapping is loaded and executed.
* For each node field that has been assigned a mapping, feedapi_mapper_map_[field_name] is being called again, this time with the arguments 'map', the feed item node $node, the feed element mapped to the node field, and the subfield it was mapped to.
Todo:
* The feed item elements should be the form elements and the node fields should fill the drop down per element. Now it is the other way round. There are 2 reasons why the feed item elements should constitute the form elements: 1) it is more intuitive - you map FROM the feed item element TO a field on the node. 2) it allows you to map different elements of the feed into the same node field - e. g. the same taxonomy vocabulary. (The reason why I haven't done this from the get go is because I had imagined the list of paths to all feed elements to be a huge messy list, but it turns out that it is not.)
* nodeapi('prepare') has to go to nodeapi('submit') - depends on feedapi_item - or is there a better pre nodeapi('save') hook to use in this case?
* feedapi_mapper_map_[field_name] has to be come a unique name - only mapper implementation functions should start with feedapi_mapper_map
* Do general mappings on a per node type basis - this is a small step away. A simple definition of standard feed items in the format that is returned by _feedapi_mapper_get_feed_elements() plus a way of storing and loading mappings on a content type basis would do the job.
Comment #13
momper commentedhello
is it to early to test? because there are a lot of already known bugs - or should we start with this nice feature :)
greetings momper
Comment #14
alex_b commentedGo ahead and check it out - don't be shy :)
Comment #15
alex_b commentedUpdate
* DONE: The feed item elements should be the form elements and the node fields should fill the drop down per element. Now it is the other way round. There are 2 reasons why the feed item elements should constitute the form elements: 1) it is more intuitive - you map FROM the feed item element TO a field on the node. 2) it allows you to map different elements of the feed into the same node field - e. g. the same taxonomy vocabulary. (The reason why I haven't done this from the get go is because I had imagined the list of paths to all feed elements to be a huge messy list, but it turns out that it is not.)
* NOT SURE: nodeapi('prepare') has to go to nodeapi('submit') - depends on feedapi_item - or is there a better pre nodeapi('save') hook to use in this case?
* DONE: feedapi_mapper_map_[field_name] has to be come a unique name - only mapper implementation functions should start with feedapi_mapper_map
* DONE: Implementations of mappers live now in their own subdirectory.
STILL TO BE DONE:
* Do general mappings on a per node type basis - this is a small step away. A simple definition of standard feed items in the format that is returned by _feedapi_mapper_get_feed_elements() plus a way of storing and loading mappings on a content type basis would do the job.
* Not sure wether mapper hook format feedapi_mapper_map_hook ("hook" to replaced by fieldname - e. g. "status") is optimal. The particularity with feedapi_mapper is that field names on nodes don't have to be consistent with module names (e. g. field_* names for CCK fields). So a hook_feedapi_mapper_map where hook is to be replaced by module name doesn't make sense. On the other hand, feedapi_mapper_map_hook is not really the Drupal way and could lead to namespace conflicts (?) or at least to the oddity of feedapi_mapper_map* functions in .module files.
Comment #16
alex_b commentedDONE: mappings on a per content type basis are possible now.
PLANNED: feedapi_mapper_map_hook will be refactored to hook_feedapi_mapper_map($field). This has the advantage that there can be more than one mapper for a field at once. Check out commentary on feedapi_mapper_map_taxonomy() function.
Latest version in sand box.
Comment #17
summit commentedSubcribing, looking interessting..
greetings,
Martijn
Comment #18
sillygwailoI tried my hand at writing a Feed Element Mapper module (to map elements to fields from the Link module) based on the Taxonomy mapper, but it wasn't obvious to me how to do it for a CCK field. I think I'll wait until the hook_feedapi_mapper_map($field) comes.
Anyway, this is my way of subscribing: FEMP solves a problem for me so that I don't have to write a script/module for each service's API when they all output RSS anyway.
Comment #19
alex_b commentedThis is a first patch against the sandbox version that changes the
feedapi_mapper_map_[field_name]($op) hook
to
hook_feedapi_mapper($field_name, $op)
(sandbox version: http://cvs.drupal.org/viewvc.py/drupal/contributions/sandbox/alex_b/feed... )
Check out how the mapper implementation of feedapi_mapper_taxonomy.inc changed now.
@Richard Eriksson: this also solves the problem on how to write mappers for CCK fields. In the mapper implementation, you can kick in on any field_* argument coming in on $field.
This patch also adds help text for users (descriptions). After consolidating this patch, whats missing to roll out the module, is cleaning up the UI on admin/content/types/node-type pages.
More to come next week,
Alex
Comment #20
sillygwailoRight on, alex_b. I committed a first attempt on the Bryght Subversion repo. What it needs to do, but doesn't do currently, is list the Link field types' machine names for the nodes of the type that the FeedAPI module creates.
Comment #21
alex_b commented@Richard: thanks for checking out the API. Helps me a lot, because I didn't come around to test the element mapper over the weekend (too much turkey :)
Did you have any problems with the patch in #19 ?
Comment #22
sillygwailoI had an issue with FeedAPI wanting an array where I was giving it an object (I isolated the error as happening at
return $node;and commenting that line out made the error disappear, and my .inc file is structurally the same as the taxonomy .inc file). Not very helpful since a) the issue resolved itself after I started with a refreshed staging environment which I can now revert to and b) I didn't think to document the issue because I was doing it right as far as I was concerned. If it crops up again, though, I'll document the content type/FeedAPI settings and the error message that it generated.Comment #23
john morahan commentedFound a typo: $maycache should be $may_cache (or vice versa)
Comment #24
alex_b commented@John: Thank you.
Comment #25
alex_b commentedI just committed the patch from #19 and #23.
Important: The order of arguments changed.
Before:
function taxonomy_feedapi_mapper_map($op, $node, $feed_element = array(), $sub_field ='');
In patch:
function taxonomy_feedapi_mapper($field_name, $op, $node, $feed_element = array(), $sub_field ='');
Now:
function taxonomy_feedapi_mapper($op, $node, $field_name, $feed_element = array(), $sub_field ='');
http://cvs.drupal.org/viewvc.py/drupal/contributions/sandbox/alex_b/feed...
Comment #26
mikeryanI pulled FEMP from the sandbox this weekend, I'm having trouble making it work in conjunction with my patch to pull in additional namespace elements. I've added a mapper for basic node fields (just aiming at the body for now):
When I refresh my feed and go to the Map tab, my additional elements show up. I switch my desired field, options->rawitem->articleText, from "No mapping" to "Map to body_filter (node module)" and click Update. I get an error "warning: Invalid argument supplied for foreach() in C:\Websites\go2\sites\all\modules\feedapi_mapper\feedapi_mapper.module on line 312." The only elements now shown are original_author->name, original_author, and tags. The mapping is not saved.
Any ideas?
Thanks.
Comment #27
alex_b commented@mikeryan: There is some problem with feed retrieval at the moment when you try to map. FEMP bails out on 312 because there are no items on the feed. I fixed this by adding an is_array() test.
http://cvs.drupal.org/viewvc.py/drupal/contributions/sandbox/alex_b/feed...
Now FEMP should fall back to standard feed item elements if it cant retrieve the feed. The standard elements are defined in _feedapi_mapper_get_standard_elements() - they are not complete. You might want to add your own elements or submit a patch that adds more standard elements to this function.
Comment #28
challer commentedI was playing around with Richard's code (#20) to do a simple map to cck field. But my mappers won't show up as available mappers nor in the dropdown. Is there a working .inc example available anywhere right now?
Here's what I got, probably pretty messy, sorry:
Thanks for your input, can't wait to see this module grow, great work!
Comment #29
alex_b commentedThere is a working .inc example that comes with feedapi_mapper.
Comment #30
challer commentedI know, but I have to realize that I'm just not good enough of a developer to figure out how to transfer the advanced code in the taxonomy mapper to a cck mapper.
As a workaround I was playing with tweaking feedapi_node.module and use $feed_item->options->original_url with the embedded media field. Saving the url is not a problem, but the module doesn't get called to extract the additional information. When feedapi saves nodes, do all the regular hooks get called? Am I missing something?
Thanks again,
Chris
Comment #31
chrisroditis commentedsubscribing!
Comment #32
alex_b commentedWhen feedapi_node saves nodes, prepare and update or insert hooks are called.
A mapper should be easy to write though.
In your module (yourmodule) create an implementation of hook_feedapi_mapper:
Or if it is not your module you would like to write the mapper for, you can create an on-behalf implementation in an .inc file, like the taxonomy_feedapi_mapper() hook implementation is an implementation on behalf of taxonomy.module in mappers/feedapi_mapper_taxonomy.inc - this approach follows the pattern how views module organizes its on behalf implementations.
Comment #33
alex_b commentedReleased :)
http://drupal.org/project/feedapi_mapper
Comment #34
jonastang commentedi see the feed element mapper very nice for specific aggregation setting, my expectation or wish is that when will be the day to be deployed to 6.x version of Druple?