0

So I have two content types Tours and Concerts. Concerts has an entityreference field that references a tour. I want to filter a view of Tours and only show tours that still have upcoming concerts. Once all concert in a tour are over I no longer want to show the tour. Is there a way to do this? Could you use hook_field_extra_fields to calculate the date and then somehow filter by that value in views?

1 Answer 1

1

The following steps should set this up...

  • Create a view of tours
  • Add a relationship of type "Entity Reference: Referencing entity" to the concerts
  • Make sure "Require this relationship" is ticked
  • Add a filter for the date field on the concert type
  • Select "Text" under "Date selection form element"
  • Ensure the relationship you set up is selected in the "Use relationship" dropdown
  • In the filter settings, change Operator to "Is greater than"
  • Change "Select a date" to "Enter a relative date"
  • type "now" under "Relative date"
2
  • Yeah, I tried that. The problem is that there is one tour and many concerts, so as soon as you add the relationship to the concerts the tour shows up as many times as it has concerts.
    – jphelan
    May 1, 2015 at 22:44
  • Actually it looks like that will work if I set Distinct to true under Query settings. I just didn't think about because most the time checking distinct doesn't seem to help.
    – jphelan
    May 1, 2015 at 22:55

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.