Scroll
Comment form programmatically
Forums
I need your help.
I want to display the comment form in the user profile in a Colorbox window.
The idea is that when I click the "Add Comment" button, a window pops up with the form inside.
I have tried different approaches.
I attempted to set variables like this:
<?php
// Store comments and the comment form in variables
function phptemplate_preprocess_page(&$vars) {
$vars['comments'] = $vars['comment_form'] = '';
if (module_exists('comment') && isset($vars['node'])) {
$vars['comments'] = comment_render($vars['node']);
$vars['comment_form'] = drupal_get_form('comment_form',
array('nid' => $vars['node']->nid));
}
}
// Unset comments from node
function phptemplate_preprocess_node(&$vars) {
$vars['node']->comment = 0;
}
?>
// Store comments and the comment form in variables
function phptemplate_preprocess_page(&$vars) {
$vars['comments'] = $vars['comment_form'] = '';
if (module_exists('comment') && isset($vars['node'])) {
$vars['comments'] = comment_render($vars['node']);
$vars['comment_form'] = drupal_get_form('comment_form',
array('nid' => $vars['node']->nid));
}
}
// Unset comments from node
function phptemplate_preprocess_node(&$vars) {
$vars['node']->comment = 0;
}
?>
But template.php does not accept this code
I also tried using
<?php print drupal_get_form("comment_form", array("nid" => $node->nid));; ?>
But this way the form displays, but the submit button is inactive, meaning the form doesn't submit. Also, for some reason, it shows the subject field even though it's disabled in the profile settings.
Please guide me on the best approach, there are many solutions for version 7, but for version 6, there's just a lack of clarity...
I would be very grateful!