Displaying author username in submitted ad (ZipsAds classifieds ads)

conielo - August 10, 2009 - 23:57

I am a total beginner with Drupal and php, and wanted to do something which seems basic but I can't figure out how, so I need help please!

Have a look here:
http://www.ibguides.com/drupal/drupal-5.19/?q=zipsads/select_location

(log in username: test
password: password
Select the first location [Aberdeen AB10] and then [community - activities])

there are two test ads there, click any.

What I want to do is to replace the default "Contact:" information which displays the email address of the person who is viewing the ad rather than that of the person who posted the ad.

Additionally I would want to replace the email address by the authors username (which would be a link to their profile) so that people can use the built in private message service rather than needing to display their email address.

Below is the code I was messing around with to try and get what I wanted (in it's original form):

I tried replacing "mail" to uid but that (obviously) just showed the user's number (the user busy viewing the page) in:

$content .= '<br><div><b>Contact:</b> '. l($user->mail, 'mailto:'. $user->mail) .'</div>';

function theme_zipsads_ad($nid) {
  global $user;
  $sql = sprintf("SELECT * FROM {node_revisions} WHERE `nid` = %d", $nid);
  $result = db_query($sql);
  $data = db_fetch_object($result);
  $zsql = sprintf("SELECT * FROM {zipsads_ad} WHERE `nid` = %d", $nid);
  $zresult = db_query($zsql);
  $zdata = db_fetch_object($zresult);
  $content = '';
  $content .= '<br><div><b>City:</b> '. $zdata->city .' <b>State:</b> '. $zdata->state .' <b>Country:</b> '. $zdata->country .' <b>Zipcode:</b> '. $zdata->zipcode .'</div>';
  $content .= '<br><div><b>Heading:</b> '. $zdata->heading .' <b>Subheading:</b> '. $zdata->subheading .'</div>';
  $content .= '<br><div><b>Contact:</b> '. l($user->mail, 'mailto:'. $user->mail) .'</div>';
  $content .= '<br><div><b>Title:</b> '. $data->title .'</div>';
  $content .= '<br><div><b>Body:</b> '. $data->body .'</div>';
  $content .= '<br><div>';
  $sql = sprintf("SELECT * FROM {files} WHERE `nid` = %d", $nid);
  $result = db_query($sql);
  while ($data = db_fetch_object($result)) {
    $content .= theme('image', $data->filepath, '', 'title', array(), TRUE);
  }
  $content .= '</div>';
  return $content;
}

So does anyone know what needs to be in the place of

"$content .= '<br><div><b>Contact:</b> '. l($user->mail, 'mailto:'. $user->mail) .'</div>';"

in order for it to display the authors username (and have that be a link to their profile)?

Drupal need support development & programming 4 sites

JackSunseri04 - November 7, 2009 - 05:51

Need programmer to help me complete four Drupal sites I need someone to help me that is very familiar with Drupal.
Call Jack 916-652-0649 or email me at JackSunseri04@aol.com

 
 

Drupal is a registered trademark of Dries Buytaert.