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->time_ago = time() - $comment->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->subject= $comment->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->Comment on Paragraph = $comment->paragraph_id;
}