I have managed to - via the help of template.php and profile_listing.tpl.php - create a nice table with my users. I start and end my taple in profile.module like this

 // Extract the affected users:
    $result = pager_query('SELECT uid, access FROM {users} WHERE uid > 0 AND status != 0 AND access != 0  AND uid != 3 ORDER BY uid ASC', 40, 0, NULL);

    $output = '<table border="0"><tr><th class="name">Name</th><th class="phone">Phone</th><th class="work">Work with</th><th class="other">Other info</th></tr>';
    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 .= '</table>';
    $output .= theme('pager', NULL, 40);

    drupal_set_title(t('user list'));
    return $output;
  }
}

And my profile_listing.tpl.php like this;

<tr>
<td valign="top">
<?php profile_load_profile($user->uid) ?>
<font class="names"><?php print $user->name ?></font><br \> 
<font class ="place">
<?php print $user->profile_place ?></font><br \>
<font class ="mail"><?php print $user->mail ?></font><br \>
</td>
<td valign="top">
<font class="phonenumber">
<?php print $user->profile_phone ?>
<?php if($user->profile_cell): ?> 
<br \><?php print $user->profile_cell ?>
<br \>
<?php endif; ?>
<?php if($user->profile_phone2): ?>
<?php print $user->profile_phone2 ?>
<?php endif; ?>
</font>
</td>
<td valign="top">
<font class="work">
<?php if($user->profile_work): ?>
<?php print $user->profile_work ?><br \>
<?php endif; ?>
</font>
</td>
<td valign="top">
<font class="work">
<?php if($user->profile_other): ?>
<?php print $user->profile_other ?>
<?php endif; ?>
</font>
</td>
</tr>

Now I would like to make it a table where the rows have alternate colors. I have tried a lot of solutions but I have not managed to do it. I guess I have to write some code in profile. module and some in profile_listing but I haven't found out where in profile.module to write it.

I use theme bluebreeze.
Anyone who can help me??

Comments

AstaC’s picture

Noone who knows?

dgorton’s picture

Typically, this is the sort of thing you would accomplish by modifying the CSS class of the < tr > tag, e.g.

<tr class="oddRow">
... content
</tr>
<tr class="evenRow">
... content
</tr>

and then declaring something like the following in your CSS file:

.oddRow {
  background-color: #cecece;
}
.evenRow {
  background-color: #ffffff;
}

You can accomplish the HTML with a snippet of PHP to alternate between those two states like this (untested snippet here:)

<?php
  $rowClass = $rowClass == 'evenRow' ? 'oddRow' : 'evenRow';
  echo ('<tr class="'.$rowClass.'">');
?>

Drew Gorton
Gorton Studios
Some of our Drupal Sites

AstaC’s picture

Thank you for your answer.
I think I was not all together clear on what I wanted. I have found solutions like the one you wrote here. The thing is I'm not good enough on PHP to know where in the code to write it. I have tried and tried but I do not get alternate rows.

dgorton’s picture

Take a look at the PHP code snippet in my original response -- that will do the necessary HTML.
So instead of writing out a < tr > with PHP (your first line) - write out < tr class=" INSERT PHP WITH CLASS NAME HERE " >

Drew Gorton
Gorton Studios
Some of our Drupal Sites

AstaC’s picture

I tried that. But I'm afraid it didn't work. Every row becomes even.

dgorton’s picture

Sorry - that's the problem with untested code snippets. I probably should have written out in longer form just so it's easier to follow in any case. Here's another attempt.

<?php
  if ( $rowClass == 'evenRow' ) { // if it's currently (already) an even row, make it an odd row
    $rowClass = 'oddRow';
  }
  else { // otherwise, make it an even row
    $rowClass = 'evenRow';
  }
  echo ('<tr class="'.$rowClass.'">');
?>

Drew Gorton
Gorton Studios
Some of our Drupal Sites