drupaldrupal-viewsorganic-groups

Drupal OG Views: cannot create view of all groups of which I am *not* currently a member


(Also posted as http://drupal.org/node/596860)

I would like to create a view showing only those groups of which I am not already a member (or a pending member). However, the obvious way of doing this (take the og_my view and change the filter "Organic groups: Group member" to false) does not work.

The reason is that the SQL query essentially returns one row for every user in the group that matches your conditions. If you're searching for yourself (as in og_my), each group node will only show up once; if you're not searching for yourself, each group node shows up N times, where N is the number of other group members. Thus the groups of which I'm already a member continue to be displayed as long as there's at least one other member.

Does anyone have a way around this?

Thanks, Adrian


Solution

  • You may not be able to achieve this in Views directly as it does not support subqueries. My SQL came out like so:

    SELECT node.nid AS nid, node.title AS node_title  FROM node node   LEFT JOIN og_uid og_uid ON node.nid = og_uid.nid  WHERE (node.type IN ('campaign','setting','system')) AND node.nid NOT IN (select nid from og_uid where uid = 1);
    

    It is said you can programmatically forward the results of such a query into the Views system for theming.

    Maybe a special handling of the argument Organic Groups:Member of a Group, Exclude Argument option?

    I also posted to d.o in hopes of pushing the issue conversation onward.