Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Some of the feeds that I am importing have feed items dated in the future. This forces them to the top of all my search results and effectively pins them there for good. I needed a method to remove those.
Following is a patch designed to work on the Publication date field from RSS importers.
Ideally it would be extended to encompass a range of dates. Eg:
From: -1Y
To: -2W
But that isn't my current use case.
Hope someone finds it useful.
Comment | File | Size | Author |
---|---|---|---|
#2 | feeds_tamper-filter_future_dates-1920726-2.patch | 2.68 KB | queenvictoria |
#1 | feeds_tamper-filter_future_dates-1920726-1.patch | 1.03 KB | queenvictoria |
Comments
Comment #1
queenvictoria CreditAttribution: queenvictoria commentedPatch attached
Comment #2
queenvictoria CreditAttribution: queenvictoria commentedUpdated to accept specific dates. Use case: Published date is sometimes not set in RSS feeds (or set to zero which can render 1900-01-01T06:00:00Z for example). Or you might just want recent articles to come in.
So invert the filter and set the date to 1990-01-01 to filter out items prior to 1990.
The new date field in this filter will accept relative times too. So you can say
"-2 years"
or
"last Friday two years ago"
or anything else supported by strtotime http://php.net/manual/en/function.strtotime.php
Leaving the date field empty will assume `now()`. So by default (without arguments) it will filter out future items.
Comment #3
queenvictoria CreditAttribution: queenvictoria commentedDoes anyone know--is the reason that testbot isn't looking at this because there are no tests written for it?
Comment #4
AlsTrying your filter, really useful considering that to skip content depending on its date is standard practice in data flows.
The filter appears in tamper, the configuration works. I can set the date, the system checks it upon save, the import results are the exact opposite if I check "invert".
However, I am not able to have the filter understand the date passed for the check. I have tried to import dates in the following formats (CSV import):
YYYY/MM/DD
YYYY-MM-DD
DD/MM/YYYY
DD-MM-YYYY
Time is never present.
The date configured in the filter falls in the middle of the imported nodes, so I should see some imported and some skipped. Instead, it is all or nothing (hence I understand that the "invert" option is working).
Thanks in advance for any help!
Comment #5
AlsAnswering my own question: the filter understands a date in Unix format (timestamp). Would be good to write it on screen in the description.
The standard Feeds Tamper package already has a plugin to convert an English date to timestamp. So, all I need now is a sed rule to tamper the CSV so my Italian dates (oh well!) become English.
Even if I am the only one who provided feedback in 9 months, I urge the maintainer of the module to include this date filter ASAP. It is really something you would expect to be able to filter on.
Comment #6
AlsComment #7
twistor CreditAttribution: twistor commentedThis should really be more generic to apply.
Also, I wonder if it would be more useful to filter by number. Either greater, less than or equal to. And just convert the date to a timestamp using another plugin.
Comment #9
Marelmel CreditAttribution: Marelmel commentedThank you for the patchs