Fresh Blurbs

Drupal: Latest Comments Block in User Profile.

In Drupal 5, if you want the User Profile page (e.g. to display latest comments by that user, you can apply a quick hack:

  1. Create or edit user.profile.tpl.php file in your theme
  2. Add the following code anywhere (wherever you want latest comments to appear) in the file:\

    <?php$output = ""; $nlimit = 7;$userid=$user->uid;// ATTENTION: status=0 - approved, status=1 in queue.$query= "SELECT c.cid, c.nid,, c.subject FROM {comments} c WHERE c.uid = %d AND c.status = 0 ORDER BY c.timestamp DESC";$result = db_query_range($query,$userid,0,$nlimit);$output .= "<div class=\"item-list\"><ul>\n";$no_comments = mysql_affected_rows ();if ( $no_comments > 0 ) {        while ($obj = db_fetch_object($result)) {                $link = url("node/$obj->nid");                $link = $link."#comment-".$obj->cid;                $output .= "<li><a href=\"$link\">$obj->subject</a></li>";        }} else {        $output .=  'No Comments left so far.';}$output .= "</ul></div>";print $output;?>
comments powered by Disqus