Drupal usernode and Profiles in table-mode Views

By John Bowen, 8 September, 2008

On a decent sized (500+ users) Drupal 5 web site, I ran into the same problem documented here, wherein the extra fields defined for users (in the Profile module) caused each user to occupy several rows of the table in a table-mode View.

Mark Peal did a nice job describing the problem, so I'll just copy/paste it here for completeness:

In the directory table, each username appears eight times.
The displayed columns in the table (after username) are first_name (1), last_name (2), and maiden_name (3). Each of the eight rows shows a combination of fields either filled in with correct data or left blank, in this pattern:
Row 1: All 3 columns blank
Row 2: Column 3 filled in
Row 3: Column 2 filled in
Row 4: Cols. 2 and 3 filled in
Row 5: Column 1 filled in
Row 6: Cols. 1 and 3 filled in
Row 7: Cols. 1 and 2 filled in
Row 8: All 3 columns filled in
And the cycle repeats for each succeeding username.

I actually ended up finding the solution in a related thread. I took that code, pasted it into a new 'news' item (with PHP Code as the input format), and viewed it to fix records. The only problem was that the script timed-out after every 35-100 records, so I had to run it several times.

In each successive run, I found the userid of the last user that had been 'fixed' by the script, then modified the script to select all users above that userid (select * from {user} where uid > 123). The effect was to take the problem in chunks, and while it took 5 attempts to get them all, it beat editing more than 500 users' profiles to get it working.

Filtered HTML

  • Web page addresses and email addresses turn into links automatically.
  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.