0

Using the Entity Registration module's built-in Views integration, I was easily able to create a view showing the events that the logged-in user has registered as attending.

Content type: Event Date field Registration field

I created a view of registrations with a relationship of registration to node.

Now, however, I would like to create a list of the content type event but only show those events for which the logged-in user has not registered.

I can add a relationship node to registration, but I don't know how to structure the filter to remove the events for which the logged-in user has registered.

  • Seems like you are looking for something like this feature - sadly, it is not implemented (yet?). Problem is, SQL does not support anti-joins in any reliable generic way, so most of generic solutions built on top of SQL databases can't do it, either. Materials I used to code similar case (or similar ones) are still to be found under this search: google.pl/search?q=sql+anti-join – Mołot Jan 28 '14 at 7:45
  • @Mołot I see, thanks for that link. Hmmm, then I suppose I'll have to add something to the module like this: drupal.org/node/2085425. That code works, but not in Views. – Patrick Kenny Jan 28 '14 at 7:55
  • If you have code that works, I think I have a way to add it to Views, for one specific case but anyway. Posted an answer, feel free to edit it with code from linked issue or clarify me on table structure. – Mołot Jan 28 '14 at 8:10
2

I'm afraid it will be hard.

Seems like you are looking for something like this feature - sadly, it is not implemented (yet?). Problem is, SQL does not support anti-joins in any reliable generic way, so most of generic solutions built on top of SQL databases can't do it, either. Materials I used to code similar case (or similar ones) are still to be found under this search: http://google.pl/search?q=sql+anti-join

Maybe there is a way to create view like that. If you only want it to work when view is filtered by one user, you could implement hook_query_alter(). Use ->hasTag() to determine if query came from the view you want to alter, and then ->conditions() to make sure it shows results for just one user (to avoid things getting messy). Then you can outer join appropriate table and (if it's our usual many-to-many intermediate table), only select rows where registration entry ->isNull().

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.