0

I have content type which have date field(multiple). It also collect the end date.

Now I am creating a view which will list the nodes of that content type.

It will sort the nodes with the start date in ascending order. And only those nodes will display whose start date is greater than the current date.

I have added the filter of start date. If start date is greater than the current date. The option Add multiple value identifier is set to Yes in the filter settings.

In the query settings I Distinct and pure distinct is checked. I have also tried the aggregation but still the view returns duplicate results.

Any Idea how will remove the dupliation?

EDIT

This is the sql query that view generates

SELECT DISTINCT node.title AS node_title, node.nid AS nid, field_data_field_event_date_time.field_event_date_time_value AS field_data_field_event_date_time_field_event_date_time_value, node.created AS node_created, 'node' AS field_data_field_event_date_time_node_entity_type
FROM 
{node} node
LEFT JOIN {field_data_field_event_date_time} field_data_field_event_date_time ON node.nid = field_data_field_event_date_time.entity_id AND (field_data_field_event_date_time.entity_type = 'node' AND field_data_field_event_date_time.deleted = '0')
WHERE (( (node.status = '1') AND (node.type IN  ('event')) AND (DATE_FORMAT(ADDTIME(field_data_field_event_date_time.field_event_date_time_value, SEC_TO_TIME(-25200)), '%Y-%m-%d\T%H:%i') >= '2014-05-15T22:19') ))
ORDER BY field_data_field_event_date_time_field_event_date_time_value ASC, node_created DESC
LIMIT 10 OFFSET 0

The problem is if an event has 2 dates then it is displaying two times and if it has 3 dates then it is displaying 3 times in the results.

2
  • can you include the sql statement as an edit to your question?
    – Geoff
    Commented May 15, 2014 at 17:21
  • sql statement added.
    – Ahmad
    Commented May 16, 2014 at 6:07

1 Answer 1

0

I have managed to do this by creating a module (easier than you might think) and adding a post execute function like this (text in caps has to be replaced by your module and view names):

function MODULENAME_views_post_execute(&$view) {
  if($view->name == "MYVIEWNAME") {
    $view->result = array_reverse($view->result);
  }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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