Index: nodecomment_views.inc
===================================================================
--- nodecomment_views.inc	(revision 1132)
+++ nodecomment_views.inc	(working copy)
@@ -2,7 +2,7 @@
 // $Id: nodecomment_views.inc,v 1.2.2.5 2007/08/15 18:29:38 robertDouglass Exp $
 
 /**
- * This include file implements views functionality on behalf of relationship.module
+ * This include file implements views functionality on behalf of nodecomment.module
  */
 
 function nodecomment_views_tables() {
@@ -19,6 +19,24 @@
       )
     ),
     'fields' => array(
+      'title' => array(
+        'name' => t('Node comment: Title'),
+        'notafield' => TRUE,
+        'query_handler' => 'nodecomment_views_query_handler_comment_title',
+        'handler' => array(
+          'nodecomment_views_handler_field_commentlink' => t('Normal'),
+          'nodecomment_views_handler_field_commentlink_with_mark' => t('With updated mark'),
+        ),
+        'option' => array(
+           '#type' => 'select',
+           '#options' => array(
+             'link' => 'As link',
+             'nolink' => 'Without link',
+            ),
+        ),
+        'sortable' => true,
+        'help' => t('Display the title of the comment node.'),
+      ),
       'nid' => array(
         'name' => t('Node comment: Parent node'),
         'help' => t('Display the node the comment was posted in response to'),
@@ -124,6 +142,10 @@
   return $tables;
 }
 
+function nodecomment_views_query_handler_comment_title($fielddata, $fieldinfo, &$query) {
+  $query->add_field('title', 'node');
+}
+
 function nodecomment_views_arguments() {
   $arguments = array(
     'nid' => array(
@@ -307,11 +329,12 @@
 /*
  * Format a field as a link to a comment.
  */
-function views_handler_field_commentlink($fieldinfo, $fielddata, $value, $data) {
+function nodecomment_views_handler_field_commentlink($fieldinfo, $fielddata, $value, $data) {
   if ($fielddata['options'] == 'nolink') {
     return check_plain($value);
   }
-  return l($value, "node/$data->nid", NULL, NULL, "comment-$data->comments_cid");
+  $nodecomment = node_load(array('nid' => $data->nid));
+  return l($data->title, 'node/'. $nodecomment->comment_target_nid, NULL, NULL, "comment-$nodecomment->cid");
 }
 
 /*
@@ -322,7 +345,8 @@
   if ($comments && $new = nodecomment_num_new($data->nid)) {
     $comments .= ' ';
     //comment_page_new_query($data->nid)
-    $comments .= l(t('@num new', array('@num' => $new)), "node/$data->nid", NULL, NULL, 'new');
+    $nodecomment = node_load(array('nid' => $data->nid));
+    $comments .= l(t('@num new', array('@num' => $new)), 'node/'. $nodecomment->comment_target_nid, NULL, NULL, 'new');
   }
   return $comments;
 }
@@ -331,12 +355,12 @@
  * Format a field as a link to a 'mark', stating whether or not the comment has
  * updated since it was last viewed by the user.
  */
-function views_handler_field_commentlink_with_mark($fieldinfo, $fielddata, $value, $data) {
+function nodecomment_views_handler_field_commentlink_with_mark($fieldinfo, $fielddata, $value, $data) {
   if ($fielddata['options'] == 'nolink') {
     $link = check_plain($value);
   }
   else {
-    $link = l($value, "node/$data->nid", NULL, NULL, "comment-$data->comments_cid");
+    $link = l($data->title, "node/$data->nid", NULL, NULL, "comment-$data->comments_cid");
   }
   return $link .' '. theme('mark', node_mark($data->nid, $data->comments_timestamp));
 }
