This is a followup question about this Old question

I have 5 flag types for a content type. consider we have 5 flag types and we don't know how many flags our user used. I mean, the first user can flag a content by flag type 1, type 2 and type 5, and other user can flag same content by flag type 2 and type 4, and etc, OK? I want to show a list of users that flagged same content, some users can use all flag types and others can use some flag types. thus I don't know users will use what flag types. You consider moreover "username", I want to show user's "E-mail". thus in this table I want to show "username", user's "E-mail" and "flag fields".

In below picture, I showed that a content can has different value. because any user can input different value in flag field. this table will appear in content page. I mean any content page has its specific table.

enter image description here UPDATE

Now I have a new Idea that I would explain. I can use Global custom text field. Consider I have 5 flag types, I added my 5 flag types username fields and hide them in views(exclude from display). As you know, First I should add flag types in Relationship part of views. when I add a username field, I should choose relationship in username field. Thus I should add 5 username fields. After that I can use REPLACEMENT PATTERNS in "global custom text". Now I have 5 patterns for my 5 username fields. Now I have a problem. Consider when one user use 3 flag types(3 of 5 flag types that I enabled for specific content), I mean when he(she) flag(s) a specific content by 3 flag types, in custom text field we can see username that repeated 3 times, because we use all 5 PATTERNS of username fields in global custom text field.

How can I solve this problem?

Is there any HTML code to show one of these patterns?

Also I can use global PHP. Is there any PHP code for this problem?

alternatives welcome also

  • Can you (also) edit your question to explain that "I want to show a list of users that flagged same content" in your question? E.g. by including an example (like some tabular format) to show how such list should look like for (eg) 3 different nodes, combined with those 5 flags (flag types), and how you then would like to see that (eg) node/123 has been flagged by 7 users using flag 2, and 2 users for flag 4 (and no users for the other 3 flags). Or are you OK with an answer containing a PROPOSAL about how such a table "could" look like? Sep 8, 2016 at 15:47
  • I added a picture in my answer, is it good?
    – Hamed
    Sep 8, 2016 at 16:00
  • Your edited question is an improvement, but I have these extra questions: (1) for flag A, what does that (blue) 6767 versus 9000 mean? and (2) you asked about same content, so where in your example do you show that "content" (I think that is still missing in your example)? Can you edit your question to also clarify these extra questions somehow? Sep 8, 2016 at 16:18
  • I added more information to my question
    – Hamed
    Sep 8, 2016 at 16:27
  • 1
    From my knowledge of Flags and Views, I'm quite certain the above table isn't possible. I'd consider creating 5 entity reference fields (one for each flag) in the user profile and then use rules to add the nodes to the appropriate reference field when flagged (and for when they're unflagged, do the opposite). That way, Views will be able to create the above table. Sep 8, 2016 at 16:32

1 Answer 1


As per the "alternatives welcome also" in your question, I would format/present the data in your table in a different format/layout. which will make the data shown in it way more easy to digest/understand.

Have a look at this alternative, which shows the same data (to which I added a few more similar sample rows to illustrate what I mean):

| User   | Email       | Flag A | Flag B | Flag C | Flag D | Flag E |
| John   | [email protected]  | 4333   |        |        |        |        |
| Jack   | [email protected]  | 9000   |        |        | 1390   | 7677   |
| Hamed  | [email protected] | 0123   | 0456   | 0789   |        |        |
| Niall  | [email protected] |        | 3377   |        | 5566   |        |

If you agree, note however that creating such table is not obvious if you're trying to do so with the Views module. However, using the Forena module (disclosure: I'm a co-maintainer), creating such table is straight forward: it's what is called a Crosstab table. This is a table with a special layout. It is formatted as a grid, with:

  • the rows representing one or more (combinations of) facts, such as countries or regions, names of persons (or users) like employees / salespeople (or user IDs / user names), names of Models, etc.
  • the columns representing one or more other facts, such as periods (months of a year, years, etc), available types/flavors of something (like types of errors), etc.
  • the intersections of rows and columns containing the actual information (data), such as summarized information (counts of something), timestamps, etc. and which might (optionally) include a hyperlink to a drill-down report.

For more info on this, have a look at the "Northwind database" demo videos, i.e:

To create such table for each "content page" (as in your question), you can use an appropriate Report parameter, which is like the equivalent of a Contextual filter. In your case, the node's id (= nid) would probably be a good candidate for such parameter. Have a look at this example report, and note the query string (= state=OH) in its URL. Just change that string to, eg,state=IL (or select some other value for state in the Parameters form) to get the basic idea about such parameter. Refer to the tutorial about Forena report parameters for more details about this topic.

This technique can also be applied to any of your entities you want to create reports about (nodes, users, whatever). For example, after you enabled Forena in your own site, you'll have access to one of its sample reports (= Active users), located at /reports/drupaladmin.active_users. If you then follow the link "logs" in that report for any of the users in the report (say with user name = SomeUserName), you'll get the (log) details about that user, via an URL similar to /reports/drupaladmin.user_logs?name=SomeUserName. So in this case the user name is used as such report parameter also.

  • It's a good way Pierre, Thanks. But I want to know can I use something likes Contextual filters in forena module? as you know, I should use "Content: Nid" contextual filter in views for this problem.
    – Hamed
    Sep 9, 2016 at 10:03
  • @Hamed : have a look at the extra paragraphs (about Report parameters) that I just added. Sep 9, 2016 at 11:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.