0

I'm getting data from a source. In the following example, there is no data in drupal database and there are 4 source "nodes" that I will import. The content type is set to create revisions.

So, first time I import data this is what I get:

enter image description here

The update date is 22/11/2015 12:00 for all 4 nodes and views has to show them all.

After half an hour, I make another import from the same source but, data 2 was deleted, so, It will not be imported.

I get this:

enter image description here

At drupal db (green block), you can see that the update date was not changed, only the other 3 nodes were changed.

Is some way (that I don't know how), I need my view to show only nodes 1, 3 and 4, basically, the latest that were updated.

Important to note that, no matter how many nodes I import, the update date will always be the same. Also, I can add fields to my content type and set values when the nodes are first imported or updated and try to use that as filters.

How can I implement this with views? Or, if not possible with views, any other suggestion?

1
  • I think "only nodes 1, 2 and 3" contains a typo, and should probably be "only nodes 1, 3 and 4" ... Also in your first line you should add "to start with", because after import there WILL be data in your DB, no? Nov 23, 2015 at 7:11

1 Answer 1

0

Drupal views support sorting with timestamps by default. You need to install the Date module to add support for date sorting in views. I also recommend that you import the data from your source with the feeds module and use another date field for your date NOT the property "updated" which is a timestamp.

Another solution is to convert the date from your source to timestamp as you import it. The tamper add on module for feeds may help you do this.

3
  • Thanks Nikos, but that doesn't solve it. Sorting by date, whatever date is, will always show data 2. I think I have to create another display, sort it by update date (latest), show only 1 result and the use that value as filter in my display.
    – zephirus
    Nov 22, 2015 at 17:05
  • make sure that the field you re checking actually contains a date in a valid format. The easiest way to do this is to enable the devel module and do something like dpm(node_load($nid_of_the_node_you_want_to_check)); from the devel php screen Nov 22, 2015 at 17:08
  • Maybe the best solution is to create a Custom Filter Handler that gives me the most recent update date value of all the nodes? Can someone teach me how can I do this? I already created the handler but not the code to get the value.
    – zephirus
    Nov 22, 2015 at 17:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.