1

I have been on this for a while, considering my low php knowledge. Anyway I would like a view that lists users with total number of articles created, total number of those articles that are published and total number of those articles that are not published per user. I have looked around for an answer to this and the closest I get is node view count which does not do what I need.

5
  • Have you tried to play with Views module?
    – Mołot
    Jul 16, 2013 at 7:48
  • yes Molot, I have used views, I have created a dropdown filter that does both published and unpublished count. Though its not what I want. I would like it to display as follows all in one row: User Name|Total Posted|Total Published|Total Unpublished And it's not a duplicate, they talk about totals, I want published and unpublished Jul 16, 2013 at 8:31
  • I think you failed to actually include a link. And please show us what you got and how you got it, too, so we could tell where you stuck and how to help. PS Edit that into your answer instead of comments.
    – Mołot
    Jul 16, 2013 at 8:32
  • resource://jid0-gxjllfbcoax0lcltedfrekqdqpi-at-jetpack/as-ff/data/edit.html That's a screenshot of it. The columns are as follows, ...record count ...real name ...First Posting (when the user's first post was created) ...Last Posting (when the user's last post was created) NOw I need to add two more columns to the same view per user; ......Total Published Nodes ......Total unpublished nodes Jul 16, 2013 at 9:19

1 Answer 1

1

In my opinion this is not as simple as it sounds although it should be considering the capabilities of Drupal.

I'll provide you with my solution (Drupal 7) which i implemented once in a site:

Create a users view in which you should do the following (in that order):

  • Remove any default Sort Criteria and don't add anything in that section

  • Add a field of "User: name"

  • Add a "User: Content authored" relationship

  • Add a filter "Content: Type" = Article

  • Add filter "Content: Published" = Yes

  • Add a contextual filter of "User: uid"

  • Activate aggregation

  • Set aggregation settings of user name field to "Count"

Now when you type the uid of a user in the "Preview with contextual filter" field of the view you will get the number of published articles that particular user has created.

Clone that view and (in the cloned view) change the Content:Published filter to No from yes. Now you have a 2nd view that gives you the number of unpublished articles for every user.

Last install and enable Views Field View module and create the following users view (in that order):

  • Add a field of "User: Uid" and exclude it from display

  • Add a field of "User: name"

  • Add a global view field. In the window that pops up choose the 1st view you created and the display you want from the "Views Settings" section (master display can be chosen if you like) and finally (and most importantly) in the "Contextual Filters field" use the [!uid] token (replacement patterns: [!uid] == User: Uid (raw)).

  • In the exact same way add a another global view field to "pull" the 2nd cloned view in this current view.

  • Recommendation: style the view as a table for trial reasons then theme as you like.
  • Also be careful to always have both global view fields after the user uid field in the Fields listing.

So this final view will present all the users of the site and next to each user the respective number of published and unpublished articles they have created. If you need the total number of articles then create an extra view without any Content: published filters and use it accordingly.

11
  • I thought an easier was was to use custom php code using views php, though Billy's method looks too complex, I will have to try it and give feedback Jul 16, 2013 at 13:10
  • Well its not simple but not complex either.once you understand the philosophy it'll be a piece of cake.
    – Billy
    Jul 16, 2013 at 15:57
  • Followed your example to the latter, is there something am missing? Jul 17, 2013 at 7:13
  • What problem do you have?
    – Billy
    Jul 17, 2013 at 9:42
  • Hey Billy, am a tad confused here "Add a global view field. In the window that pops up choose the 1st view you created and the display you want from the "Views Settings" section (master display can be chosen if you like) and finally (and most importantly) in the "Contextual Filters field" use the [!uid] token (replacement patterns: [!uid] == User: Uid (raw))." Jul 17, 2013 at 10:48

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