I want to provide this option that users be able to put comment on each paragraph of an article that a user has posted in Drupal.

I have applied some changes to node.tpl.php file, like

$paragraphs = explode("<p>",render($content));

so I can render each paragraph with a for loop, like:

 for ($i=1;$i<$number;$i++)
 print render($paragraphs[$i]); 

Now, I want to write a module to provide the commenting option for each paragraph. I will use hook_node_view function to define a new field like:


which is similar to


but the new one I am defining is a 2 dimensional array. so after

   print render($paragraphs[$i]);  // in node.tpl.php 

I can write

   print render($content['paragraphcommnet'].

But I need to know in which file $node->content['comments'] is defined. If anybody can help me with I would really appreciate it. Also if you think my solution is wrong, please let me know.

Thank you

1 Answer 1


Have you looked at modules that may provide similar functionality like:

  1. https://drupal.org/project/annotator
  2. https://drupal.org/project/annotate

Other links:

  1. https://groups.drupal.org/node/72748
  2. https://github.com/patrickmj/Open-Review
  3. https://groups.drupal.org/node/10875

They may not solve the problem you have but they may have code solutions that can help you go down the correct track

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.