1

I'm trying to build a view containing two columns: first is the actual value of a (integer) field, second is the same field with its old value from two weeks before, using the revision. I suppose I would need a relationship for the second one but can't figure out how do to so.

The great Diff module help comparing one node at a time, but I would need to compare a list of nodes, reason why I want to do it in a view.

Any help would be more than welcome!

4
  • do you want all the values in the revision or just one value from two weeks before? – Mohammed Shameem Jan 23 '13 at 13:16
  • Would be the value from two weeks before, reason why I thought maybe it could be handle with a (date) relationship to the node revision... thanks for asking – Ned Jan 23 '13 at 13:22
  • Well actually if you have any solution to see all values maybe I could dig a bit more in this direction... – Ned Jan 23 '13 at 15:39
  • There's a view type for revisions instead of "content". Have you tried that? I've done similar to this before with the UI. – Niall Murphy Dec 11 '16 at 4:24
1

This is a bit of a hackish solution.

What you need to do it create a field which would be unique per node on all the revisions. You could use the Computed Field instead of the normal field to crate this field and use the code below to computed the field

if (!$entity->nid) 
{
 node_save($entity);
}

$entity_field[0]['value'] = $entity->nid;

This would set the value of the computed field to the nid of the node so that you dont have to bother about setting a unique value.

Now in the views create a view of the type content revision. (This would be done by selecting content revision from the dropdown near Show

Add the fields for which you want the revision data. Use the one which says (historical data) at the end of it.

Now add the contextual filter with the computed field we created earlier. make sure the select the one with (historical data) at the end of it.

In the filters you can choose Content revision: Updated date and select the date range you want. you can also provide relative values such as -7 days to get the all the values before 7 days.

The computed field was used because I was not able to get the nid of the revisions. If any one has a work around on that please do make the required changes.

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.