limiting number of feed items
LouBabe - June 21, 2009 - 19:50
| Project: | FeedAPI |
| Version: | 6.x-1.7-beta2 |
| Component: | Code (general) |
| Category: | support request |
| Priority: | normal |
| Assigned: | LouBabe |
| Status: | patch (to be ported) |
Description
I want to limit the number of items returned for a given feed and couldn't find a way to configure using the FeedAPI or any of the default parsers or processors. I actually wrote my own simple processor and am able to set a limit that way, but it looks like this needs to be done at the parser level. E.g., at the processor level, I am only storing 3 items, but the parser still reports 10 items as processed. Thanks!

#1
Well, "Delete news items older than" filters out old items, so the processor does not need to process old items. However, for the number of items, feedapi lacks such a feature. Can you outline a good use case? I wonder if it's useful for other users as well.
#2
I need this exact same feature, and also wrote my own simple processor but am coming up against the same realization. It needs to be restricted at the feedapi / parser level. Simply put, an application may only want to process X number of the most recent items from a given feed. Perhaps due to limited display space, wanting to show content from many feeds in a single space, etc.
What's the best approach? I'm happy to write a patch.
#3
+1
http://drupal.org/node/473000
#4
Well, if you really want to step up with a patch, I can suggest the following:
1) A new setting is surely needed, put it into feedapi_feedapi_settings_form()
2) Do it on feedapi level, in _feedapi_call_parsers() you can restrict the size of the $feed->items() array.
#5
Attached is a first stab patch, adding a setting at the feedapi level for max items, and applying it in _feedapi_call_parsers() to the $feed->items array. It seems that this is better handled by passing the setting to the parser, though, as it would be more efficient to not have it process all the items that are not going to be used. Thoughts?
#6
Found a problem with this patch and could use some help from then maintainers. The max items setting is respected when a feed node is created, but not edited. What's the best way to trigger in both events?