0

In Drupal 7, I'm building a module that has a view page that lists all nodes of a certain type. I want users to be able to comment on each node in the view from this view page.

I tried using hook_node_view but it only seems to apply to the full node page view. What kind of hook do I need to get the comment form of a node in a view?

2

What I know? That you can use the view.tpl.php file and add:

<?php
print drupal_render(drupal_get_form("comment_node_**content_type_machine_name**_form", (object) array('nid' => **$node->nid**)));
?>

Change the bold according to your node object and the content type machine readable name.

I think this link can help you too. and I suggest to check hook_views_pre_render Here which can do it but I didn't try it before.

| improve this answer | |
  • Thankyou, I must apologise but I'm building a module - so I can't put this in the theme template. I need a hook to override the theme some how? – Confused Drupes Aug 22 '12 at 8:02
  • You can check this answer: drupal.stackexchange.com/a/53689/1431 to see how you can override a template from your own module and then try the solution mentioned here. – Amarnath Ravikumar Dec 23 '12 at 17:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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