I have the attached view which has the settings:

  • Two relationships: 1) Flags node (Include only flagged content, unchecked; By Any user). 2) Flags user which uses the Flags node relationship.
  • Argument: User uid; Relationship: Flag user; Provide default from url: User id from logged in user; Validation criteria: me (me module); Only allow numeric uid.
  • Filter: Flags flagged; Exposed; Required; Status defaults to True; Relationship: Flags node;

The view works perfectly for flagged content. However the unflagged content does not show whenever the filter is changed to false. If I make the filter statically set to false it also will not show anything. Any ideas?

CommentFileSizeAuthor
flag-argument-view.txt7.67 KBnicholas.alipaz
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

nicholas.alipaz’s picture

I guess I see the problem after turning on the preview of the SQL:

SELECT node.nid AS nid, node.title AS node_title
FROM 
{node} node
LEFT JOIN {flagging} flagging_node ON node.nid = flagging_node.entity_id AND flagging_node.fid = '2'
LEFT JOIN {users} users_flagging ON flagging_node.uid = users_flagging.uid
WHERE (( (flagging_node.uid = '35' ) )AND(( (node.status = '1') AND (flagging_node.uid IS NULL ) )))
ORDER BY node_title ASC
LIMIT 20 OFFSET 0

No way it is going flagging_node.uid IS NULL will work when flagging_node.uid = '35' is there. I will probably have to resort to two views displays and a ctools jump menu between the two I think.

joachim’s picture

> Flags node (Include only flagged content, unchecked; By Any user

With this relationship, assuming it's set to 'required', you'll only ever get flagged content.

nicholas.alipaz’s picture

Actually, retracting my last statement, it seems there may be no way to do what I am seeking. I need to show a list of nodes that are flaggable by my flag but this particular user (in the url argument) did not tag. Any ideas on that?

nicholas.alipaz’s picture

I have opted to add a new display with a path of user/me/collection/missing and then I have:

  • One relationship: Flags node (Include only flagged content, unchecked; By Current user).
  • Argument: none
  • Filter: Flags Flagged; Status False; Relationship: Flags node;
  • And some more filters to filter out content I don't want.

It works but not quite what I had in mind. I will make due.

joachim’s picture

Like this perhaps:

node -> flag relationship (not required)

Then add a filter ON the relationship for the Flagging UID, set to the user you want.
Then add another filter on the flagging that filters OUT anything that's not NULL.

nicholas.alipaz’s picture

Perhaps I am misunderstanding but wouldn't a filter ON the relationship for the Flagging UID not be an adequate solution if I need to pass in the UID as an argument?

joachim’s picture

That would get you all the nodes whether they are flagged by your user or not, and the flagging status is they are.

nicholas.alipaz’s picture

Status: Active » Fixed

I still don't follow your suggestion really, sorry. I think that would require a hardcoded UID in the filter section. UID has to be passed in as an argument. I did get a solution however, so no worries. Thanks for trying to help.

joachim’s picture

See https://drupal.org/node/299335, which is actually linked to from the UI.

nicholas.alipaz’s picture

joachim, yes I did use that guide but if you follow that and consequently attempt to add a UID as an contextual argument while allowing flagto the view it no longer works because the query then becomes something like, where uid is null AND where uid = X, which obviously will not workout.

Please note that I do not remember the exact query, I have since remade the view and have a working solution, but was not able to utilize the exposed flagged filter. I am however quite happy with the solution I came up with.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.