Greetings,
Is it possible to render a comment form in a view? I have not been able to find anything that works, yet it seems pretty basic. I appreciate any advice. Thanks.
Greetings,
Is it possible to render a comment form in a view? I have not been able to find anything that works, yet it seems pretty basic. I appreciate any advice. Thanks.
Comments
Comment #1
bshaddad commentedHi,
You can add the below code to views custom template:
Comment #2
pyxio commentedHi
Thanks so much for this! Unfortunately, I get the following error though.. is there a solution? Cheers Kevin
Notice: Undefined variable: node in include() (line 62 of /var/www/html/panelize/sites/dixit.panelize.it/themes/dixit/templates/view/views-view--product-detail--view-product-reviews.tpl.php).
Notice: Trying to get property of non-object in include() (line 62 of /var/www/html/panelize/sites/dixit.panelize.it/themes/dixit/templates/view/views-view--product-detail--view-product-reviews.tpl.php).
Notice: Undefined variable: node in include() (line 62 of /var/www/html/panelize/sites/dixit.panelize.it/themes/dixit/templates/view/views-view--product-detail--view-product-reviews.tpl.php).
Notice: Trying to get property of non-object in include() (line 62 of /var/www/html/panelize/sites/dixit.panelize.it/themes/dixit/templates/view/views-view--product-detail--view-product-reviews.tpl.php).
Notice: Undefined index: comment_node__form in drupal_retrieve_form() (line 763 of /var/www/html/panelize/includes/form.inc).
Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'comment_node__form' not found or invalid function name in drupal_retrieve_form() (line 798 of /var/www/html/panelize/includes/form.inc).
Comment #3
bshaddad commentedHi,
You need to load the node before:
<?php $node = node_load(arg(1));?>Where arg(1) is the node id in the url:
example.com/node/1 (if you are trying to print the form in a node's page)
Comment #4
pyxio commentedI see. But the problem is there are many nodes. For example, a product page and each one has a comment form like standard drupal page. so the node id will change per page. is there a variable that can be used instead of a fixed node id?
Comment #5
bshaddad commentedarg(1) will get the node id from the url, it is not static.
Comment #6
pyxio commentedMost excellent! Huge thanks for taking the time to share the code with me. Works perfectly!
Comment #7
mustanggb commented