Using profile module, setup a checkbox field, hoping to use views page to return a filtered set of users. Trying to solve two issues at the moment with the view:

1) In another older post, saw that users must have created a node, not just completed their profile in order to show up in a view. Is this still correct?

2) Getting repeated results, when filtering only by the profile checkbox field. Would expect to only get one Unique result for each user name / user picture. (Might be getting one per post submitted?)

Seems very close. Hoping there is an end-run on #1, so can filter just on profile questions in a view - without turning users into nodes, setting up nodeprofile, family, sub module... I tried that already, but seems like extra overhead for this task.

Thanks,
-Greg

Comments

adrinux’s picture

I'm having a few views+profile problems myself, although probably not the same as yours: http://drupal.org/node/144839

You don't mention which version of Drupal you are using, note that there is a bug in 5.1's profile module http://drupal.org/node/119114 - sounds like that might be an issue for you. It's fixed in DRUPAL-5 head (which will become 5.2).

merlinofchaos’s picture

Status: Active » Closed (works as designed)

Note that if you do not have users somehow attached to nodes, users that have never authored a node cannot show up. So 1) is correct.

Because of this, you will also get 1 result for every node that a user authored. That is why 'usernode' module is currently required to get Views to do a proper list of users.

Unfortunately, that is a problem at the core of Views. I plan to fix this for Views 2, but that'll be Drupal 6 only, so it is likely not a solution you can use for several months at the earliest.

greg@beargroup.com’s picture

Status: Closed (works as designed) » Closed (fixed)

Thanks Merlin. Closed this, as it seems like a known issue with Views which wasn't meant to handle users. I ended up just adding a profile checkbox, and using this bit of code in a page to render a normal profile page without views.


// Compile a list of fields to show.
$fields = array();
$result = db_query('SELECT name, title, type, weight FROM {profile_fields} WHERE visibility = %d ORDER BY category, weight', PROFILE_PUBLIC_LISTINGS);

while ($record = db_fetch_object($result)) {
      $fields[] = $record;
}

// v.fid = 1 is the include in member gallery checkbox
// If the field contains integer values use ORDER BY ABS(v.value) to force numeric sorting

$result = pager_query("SELECT u.uid, u.access FROM {users} u INNER JOIN {profile_values} v ON u.uid = v.uid WHERE v.fid = 1 ORDER BY v.value ASC", 40, 0, NULL);

$output = '<div id="profile">';
while ($account = db_fetch_object($result)) {
 $account = user_load(array('uid' => $account->uid));
 $profile = _profile_update_user_fields($fields, $account);
 $output .= theme('profile_listing', $account, $profile);
}
$output .= '</div>';
$output .= theme('pager', NULL, 20);

return $output;

Views is super cool... having fun exploring it. thanks for building it.