I want to create a view that list out the following fields

  1. User name
  2. User email
  3. Discussion count
  4. Blog count

I created the view and add the User: Name and User: Email in the fields but it shows me the duplicate users and Also I have no idea about how to add the discussion count and blog count to the view.

I have created the view of node type. Any help?

  • Can you explain in a bit more detail what that "blog count" should exist of? Is that the number of blog-posts a user made? And if, so, what is considered a "blog-post"?
    – berkes
    Sep 14 '11 at 8:39
  • Yes it is the the number of the blog posts a user made.
    – Ahmad
    Sep 14 '11 at 12:26
  • And "Blog posts" are that nodes of type "blog"?
    – berkes
    Sep 14 '11 at 12:31
  • yes thay are of type "blog".
    – Ahmad
    Sep 15 '11 at 5:59

I'm going to take a stab at answering this. Create a view where:

Under Fields you select the User name, email and User:Uid. Then add a custom field. Under the custom field write a query in Value:

<?php $result = db_result(db_query("SELECT COUNT(nid) FROM node where uid='%s' and type='blog'",$data->users_uid)); 
echo $result;

This query find the number of posts written by each user.

Under filters choose Node:type = 'content type used to store profiles' (as you want to count the number of blogs of every user who has a profile).

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.