Views + Profile fields != User List

Events happening in the community are now at Drupal community events on www.drupal.org.
Michael Hofmockel's picture

edit: This is only for Drupal 5. With Drupal 6 and Views 2 you can enumerate users.

Last Night at our meeting I was sure that views could not be used to create a list of users using profile fields. As to my knowledge, views is solely based on Nodes. Every view must be in context of a node.

I was proven wrong when someone quickly pulled up a views edit page and showed profile fields in the fields pull down.

Not so fast! I investigated this further and found that the truth lies somewhere in between. The conversation at the time was revolving around enumerating users not nodes. Someone suggested using views to enumerate the users. You can not enumerate users with views!

Although you can pull profile fields into your view, those fields will always be in context of a node. Meaning, you can create a list of nodes and show the profile fields of the associated author UID of that node.

BUT you can not create a list of users showing only their profile fields. Try it and you will understand better. Create a new view that has only profile fields. You will get one record for every node they have created. If they have not created a node then they will not be listed.

If you are really interested in imperical truth the function that builds the view can be found in views_query.inc. There you will see that all queries built with views hinges on the node table.

The handbook title for the Views module says it all "Views: Customized Node Lists" - http://drupal.org/handbook/modules/views

If you want to use views to enumerate the users you must present users as nodes. But thats another can of worms.

Comments

Users as Nodes?

knausz's picture

Hi, I saw your explanation here, nice job.

As for the can of worms - what is the best way to present users as nodes so I can create a list of users so that they can contact each other? Is it usernode, node profile, or something else?

I'm using Drupal 5.7 and can't switch right now to 6. I understand that Views 2 (which is only available in Drupal 6) will be able to build queries on any data and not just nodes, but that doesn't help since I'm running in 5.7.

Thanks!

-Imre

Bio is the way!

Michael Hofmockel's picture

I have come to really like the Bio module - http://drupal.org/project/bio
It works like you expect it.

I usually use the following modules in combination as well.
- Email Field to handle email accounts. Can hide accounts and use a contact form instead. - http://drupal.org/project/email
- Token to handle auto filling the email field from the email already in the user profile - http://drupal.org/project/token
- Pathauto to give the user a url that is their name - http://drupal.org/project/pathauto
- Auto_nodetitle to hide the title from the user. In this way you can have first and last name fields so you can fully sort and search on them. But again with the token module the first and last names can be recombined and used as the title of the node. I then hide the first and last name in the node display because it is already in the title.

Then of course you can build out the bio content type with other fields and use views to list the bio nodes. Thats how I'm doing it.

Also look at this to enforce bio node creation - This may have been solved in the latest release of bio module but I'm not sure - http://drupal.org/node/162121#comment-626038

Regards,
Michael Hofmockel
Hofmockel

Open Source || Open Access || Open Mind

Regards,
Michael Hofmockel

Open Source || Open Access || Open Mind

usernode + views, or views 2

wmostrey's picture

I blogged about this today: Creating a list of users. For Drupal 5 the combination of a user-as-node module + views is the way to go. The usernode module comes with a nice default view for this but bio would work just as well. There's node profile too but that might be a bit too much if all you need is a list of users.

For Drupal 6 there's no need for such a module, you can just use Views 2.

Ann Arbor, Michigan

Group organizers

Group categories

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: