简体   繁体   中英

Drupal Views complex query: filter only relationships

I've a problem with a complex query. I've a node type Event and the list of users. Between events and users may exists (or may not) RSVP relations created with the Relation module ( https://www.drupal.org/project/relation ). Inside any relation there are infos about the RSVP (presence, invites, ecc.). I need to make a page where I show next events with related RSVP informations about current logged user. I won't cover event filtering problem, the main problem is that not every event<->user has an RSVP relation, but only where the users has been interested about the event (why is obvious).

My incomplete solution was: starting from event list, filter only events which I'm interested in, create a relation "node<->RSVP relation" for get RSVP relation's fields, from previous relation, create a new relation "RSVP relation<->user" to get the linked user filter only user that is the currently logged in

This solution works only if the event<->current user RSVP relation exists! If it doesn't exist the event disappear where I want to show it without any RSVP informations.

My last idea of solution goes in direction of a filter applied only on relations and not to events, or the possibility to make two views (events and current user's RSVPs) and left join them. My old idea was to accept (I don't know how) also events without an event<->current user relation, but I realized that this solution may accepts all event<->!current user relations and I don't want this.

How can I do? Thank you!

You should start checking if you set relationship as required. The difference will be an inner join instead of left join. Check the query to see what join are you getting

最后,我用Drupal的模块Views Field View解决了问题,其中包括一个View,该View在列出事件的另一个View中选择RSVP信息。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM