I want to create a view that displays all forum topics a user posted, plus added in that same view all forum posts to which the user commented. I can't figure out how to do this. It's easy to create a view that displays a user's forum posts. I also managed to create a view that displays all forum posts to which the user commented. (I used a relationship "Comment:Node" and added a filter that says the user id from the relation must not be the current user. I basically want the combination of both results in one (sortable) table.
Please note that this is exactly what the standard Drupal track page for a user does (except that's not just forum topics).
I would be able to create this view if I could specify two filters and specify that they have a boolean OR relationship, instead of the standard AND relationship.
Am I making sense? I find it difficult to explain. Let me phrase it completely differently.
If I create the first view I described above, and then add a relationship "Comment:Node", I get a view with the following query:
SELECT node.nid AS nid,
node.title AS node_title,
users.name AS users_name,
users.uid AS users_uid
FROM node node
LEFT JOIN comments comments ON node.nid = comments.nid
LEFT JOIN node node_comments ON comments.nid = node_comments.nid
INNER JOIN users users ON node.uid = users.uid
WHERE node.type in ('forum')
I want this query, but somehow add the following condition to the where clause:
AND (comments.uid=***CURRENT_USER*** OR node.uid=***CURRENT_USER***)
Any help is much appreciated. (I'm considering writing a custom filter, but I don't know how to do that yet.)
Comments
Comment #1
svdoord commentedOk, I got it to work using (what feels to me like) a work-around. I created a custom Drupal module and implemented the hook views_query_alter:
I still would like to know if I can do this without resorting to custom modules and PHP code, but it's less urgent now.
Comment #2
merlinofchaos commented...why don't you just look at the 'tracker' view that comes with Views, which does what tracker.module does?
Comment #3
svdoord commentedWhat the "tracker" view does is different from what the standard "track" tab inside a user's profile displays (which is what I was referring to). Tracker displays all articles, I only want the articles written by OR commented on by a specific user.