On my site, I have content types for Tradeshows and Webinars. I would like to have a block that shows the next 5 upcoming events by date, coming from either content type. I have Views set up to retrieve items from both types, and have the sort criteria set up with the date field from each type (they are different fields), in ascending order. Ie., the Sort Criteria section looks like: Webinar Date (asc), Tradeshow Date (asc).

If I set the Views pager to display all items, I see a list of all the tradeshows, followed by the webinars. It looks like Views retrieves the items from each content type, and sorts them correctly within their own group, but doesn't weave the two sets together, according to date. This means that if I set the pager down to 5 items (the goal), then I'll only see tradeshows, since there are more than 5.

Is there a way to get Views to shuffle the two types together, and show the next 5 events, combined?

Edit: attaching screenshot enter image description here

  • can you give us a screen shot of your Views UI and how you are sorting? From comments below, it appears that you don't have a common field on which to sort, and if that's the case, well, then that's the issue right there: Views is sorting on one field and then sorting on the other, and things are getting aggregated accordingly. Thus, you might need to put another hidden field in the nodes that is populated from whichever field is there and then sort on that field.
    – Jimajamma
    Mar 20, 2014 at 19:58
  • I guess Views is doing its sort on the first content type before retrieving the second set. If it pulled all the data and then sorted, it should use whichever of the two fields is present. I think you might have hit on the solution, though. I've already been using Views:Conditional to populate a field with the type selected. I could make another one for the date field, and use that to sort. I'll try it and report back. Thanks for the idea!
    – eljefejb
    Mar 20, 2014 at 20:38
  • No joy. Views won't allow you to pick a Views:Conditional field for sorting. It has to be a field from the content type. :(
    – eljefejb
    Mar 20, 2014 at 20:59
  • 1
    You can turn on the sql preview to see what exactly Views is doing, but since there is no common field between the content types, it doesn't know how to aggregate this seemingly totally different fields. So, unless you create a common date field between these node types, this is what you are going to get. You can create one as I mentioned in my first comment and have it populated (via hook_node_presave()) from whichever of these fields is in fact present in the node and then sort on this new field.
    – Jimajamma
    Mar 20, 2014 at 21:43
  • I'm afraid you've lost me there. I'm learning, but that's still beyond my ken!
    – eljefejb
    Mar 20, 2014 at 22:46

2 Answers 2


In the end, using hook_views_query_alter() turned out to be the simplest solution for my needs. I used code similar to that found in the solution below.



Use Same field to pick date for Tradeshows as well as Webinars using existing field in content type. After that sort view accroding to that date field.

  • The date fields are not the same between the two content types. Webinars have a combined date/time field, and Tradeshows have a combined start/end date.
    – eljefejb
    Mar 20, 2014 at 18:10

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.