logo

Extra Block Types (EBT) - New Layout Builder experience❗

Extra Block Types (EBT) - styled, customizable block types: Slideshows, Tabs, Cards, Accordions and many others. Built-in settings for background, DOM Box, javascript plugins. Experience the future of layout building today.

Demo EBT modules Download EBT modules

❗Extra Paragraph Types (EPT) - New Paragraphs experience

Extra Paragraph Types (EPT) - analogical paragraph based set of modules.

Demo EPT modules Download EPT modules

Scroll

Comment form programmatically

22/02/2025, by Anonymous (not verified)
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;
}
?>
 
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!