2

I have 2 flag types for a content type. both flags have flag field. consider the user flagged a content by both flags. I want to show user data. I have problems in this situation. I add flag A and flag B in relationship part of views, after that I add "username of user" and "flag field" in fields part. but unfortunately I should add 2 "username" field, one of them should relation to flag A and other should relation to flag B(relation part in field setting). this is problem. because I want one field of "username", not 2 "username" fields. What should I do?

4

Add a filter for the whole view that checks username in both fields as not null, and set the operator to 'And'.

In your view under 'Filter Criteria' do the following:

  1. Add user name with the first relationship and set the operator to 'is not empty (NULL).
  2. Do the same for the second username field.
  3. Click the dropdown arrow next to add for 'Filter Criteria'. Select And/OR, Rearrange and add an 'AND' operator between the two filter.
  4. Hide the second username from display.

That way you can filter for users with both flags.

  • Could you explain more? because it didn't work, maybe I didn't understand good – Hamed Sep 7 '16 at 16:10
  • I added more points under my initial answer. – Jed_BH Sep 7 '16 at 18:02
  • @Hamed : the "hide" (item 4) is actually the views option "Exclude from results". Maybe that's the part you didn't understand? – Pierre.Vriens Sep 8 '16 at 6:49
  • Thank you Balmong, work great. Dear Balmong and Dear Pierre I asked new question about this problem here. drupal.stackexchange.com/questions/214185 – Hamed Sep 8 '16 at 15:05
1

It seems that the crucial part of your (updated) question (as in revision 3 of it) is that you need use filters that are related to "either of your 5 flags", which means that Views should use an "OR" (instead of "AND", which is the default) in its query.

To make that possible, you can use the Views Contextual Filters OR module (which only has a dev version today, though close to 2K sites are using it).

Excerpt from its project page:

... provides a views plugin which modify query to support OR conditions for contextual filters.

... A new option will appear in settings page query. If the option is enabled the query will be rewritten using operator OR.

Have a look at the image below (also from the project page), near the bottom of it there is a checkbox titled "Contextual filters OR":

enter image description here

So after you enable this module and check this checkbox, you may get it to work. To actually do so, you need to enhance/correct the view you already seem to have, similar to what is detailed already in the answer from balmong. But for the filter criteria make sure to use "OR" (instead of "AND"), and make sure you do so for all your 5 flags (as in your updated question, so not just for the 2 you originally mentioned).

  • I should use OR in "Contextual Filters" !? I enabled it now, what should i do after that? – Hamed Sep 8 '16 at 10:43
  • 1
    See my updated answer. If that still doesn't help (or is not sufficient), then please update your question by adding a screenprint of how the view you already have looks like (using the views UI). – Pierre.Vriens Sep 8 '16 at 11:09
  • Dear Pierre I asked new question about this problem here. drupal.stackexchange.com/questions/214185 – Hamed Sep 8 '16 at 15:06
  • Looks like you performed the equivalent of a rollback from revision 3 to your original question. Since my answer related to revision 3 of it, the best I can think of is to add a link to that revision in my answer also ... – Pierre.Vriens Sep 8 '16 at 15:33

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.