How can I use hook_comment_view? I have added a new field to comment table, called "paragraph_id", I have also added a field to comment form that ask users which paragraph they want to put comment on and what they enter will be saved in "paragraph_id" field.

So now I want to show the value of "paragraph_id" in the comments, beside showing the subject and the body of the comment. 

There is a hook called "hook_comment_view" , and it can be used to add additional data to the comment before theming.

This is the hook:

function hook_comment_view($comment, $view_mode, $langcode) {
  // how old is the comment
  $comment-&gt;time_ago = time() - $comment-&gt;changed;
}


I tested this hook by changing it to the following:

function Annotations_comment_view($comment, $view_mode, $langcode) {
  // how old is the comment
  $comment-&gt;subject= $comment-&gt;paragraph_id;
}


and instead of subject it showed the data in paragraph_id field. But how can I add a new field to comment display form, for example called : Comment on Paragraph

and then write this:

function Annotations_comment_view($comment, $view_mode, $langcode) {
  // how old is the comment
  $comment-&gt;Comment on Paragraph = $comment-&gt;paragraph_id;
}
First, PHP is case sensitive - don't start your function names with capital letters, it's bad practice, capitals are generally reserved for Classes.

Secondly, if you haven't already, install the devel module, it's really useful.

Then you can look at the structure of the $comment object that is passed to the hook by putting dpm($comment); inside your hook.  Make sure you give yourself the permission to view devel information.

Once you can see the structure of the variable it should make sense what drupal is doing with it.  You can add a new element to the form simply by editing the $comment variable:

$comment[#myNewElement] = array(
  'property1' =&gt; 'value1',
  'property2' =&gt; 'value2',
  'property3' =&gt; 'value3',
);


You can learn about the various form elements and their properties at the Drupal form API.

You will probably need to query the database to get your display value before you set the element.

Happy coding!