3

I created a view to show Users. These users can create nodes of the "Questions" content type.

The view has to render a table to show how many (the total number) Questions the user has created. Something like:

User +++ Questions created
John --- 10
Ted  --- 4
Alf  --- 19
7

you have to use the Aggregation setting and active it in your view.

  1. Activate Aggregation. (It's in the "advanced settings" of the view)
  2. As your view is a view of users, add the relationship "User : content authored". If you set the option "Require this relationship", you'll skip users with no nodes created (can be useful)
  3. Add your user name field, don't use aggregate
  4. Add a node field, let's say Node : nid with the relationship set
  5. Use Aggregate for this field, "Count DISTINCT".

Have fun !

| improve this answer | |
  • PS: I hope you're using Drupal 7. – Gregory Kapustin Dec 12 '12 at 16:18
  • Make sure the result is sorted by the field you are aggregating, in this example NID – Francisco Luz Dec 12 '12 at 22:04
  • It works but it shows all the content types. How do I narrow to the "Question" content type? – chefnelone Dec 13 '12 at 12:38
  • Add a filter node : type with the relationship – Gregory Kapustin Dec 13 '12 at 12:44
0

This question is a variation of what the purpose is of one of the Out-of-the-box examples that you get after install/enable of the Charts module, and without any additional configuration.

By doing so, a new view is added to your site. Here are some more details about it, quoted from the linked page above (to which I added some formatting here):

You can see the charts created via this new view in your own site by navigating to charts/examples or by using a menu link with a title like Charts examples. After doing so, a page is shown with 2 sub-menu tabs:

  • the first tab is titled Built-in examples (this example is used to showcase Using the Charts API).
  • the second tab is titled Views example, and is what is created from the new view created during the installation of the charts module. As an alternative to using this tab, just navigate to charts/examples/views in your site. You should then see a column chart and a pie chart, which are followed by a tabular display also. Both charts and the table display contain data about the total number of nodes for each of the available content types.

To massage this out-of-the-box sample to match the question here, all that's needed is to add some appropriate fields (related to the users) and some filter(s), like node type. Done.

Disclosure: I'm the maintainer of this module,
I hope this does not violate the site's policy on self-promotion.

| improve this answer | |

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.