How can I display the comment form in a popup. I want the functionality when I click on the link "add new comment" on a node, the comment form should appear in a popup window.

Any one who have some idea?

  • You mean real popup, a window from your browser or a modal box, like dialog from jQuery ?
    – yvan
    Aug 25 '11 at 5:40
  • I mean a dialog from JQuery.
    – Ahmad
    Aug 25 '11 at 5:48
  • Have you tried colorbox or fancybox modules? I have tried those with forms. It may work with comments also.
    – Hacker
    Oct 19 '11 at 12:48

Well, for it I can propose you a 'sexy' solution.

  var comments = elem = $('#comments'); // I get the element comments
  if(comments.size() > 0) { // I check if is exist
    // Here I remplace the form with a link
    var link = elem.replaceWith('<a href="#comments">'+ Drupal.t("Comment my node") +'</a>');
    // For the new link I give him a OnClick event.
      // Here I just hide the submit button, you can hide other buttons as well
      $('input[type=submit]', comments).css('display', 'none');
      // Here the dialog from jQuery UI you can change is as well
        buttons: {
          "Comment": function() {
              $('form', comments).submit();
          "Cancel": function() {
        modal: true,
        height: 245,
        width: 475,
        title: title,
        open: function() {
        close: function() {
        resizable: false,

You've to include this code in the header or footer of your theme (better if you can check before if you're on one page with comments or not. And be sure that jQuery UI Dialog is also loaded with drupal_add_library.

P.S. I didn't try the code, so maybe you'll find some bugs, but the main idea is there.

  • How should I include the jQuery UI Dialog? Is it drupal_add_library('jQuery UI Dialog')?
    – Ahmad
    Aug 25 '11 at 6:43
  • Like this ´ drupal_add_library('system', 'ui.dialog');´
    – yvan
    Aug 25 '11 at 6:53
  • I have copied your js code to popup.js file. Then In the module file and in the form_alter function I added ´ drupal_add_library('system', 'ui.dialog'); drupal_add_js('popup.js'); Is it fine? As it did not work for me.
    – Ahmad
    Aug 25 '11 at 7:11
  • Put your popup.js into your theme folder. After in your template.php add drupal_add_js(path_to_theme() . '/popup.js'); drupal_add_library('system', 'ui.dialog');
    – yvan
    Aug 25 '11 at 7:15
  • My default theme is bartik. I put the popup.js file in the bartik folder and then I added those two lines at the end of the template.php file. I replace the path_to_path() with themes/bartik. But still it does not work.
    – Ahmad
    Aug 25 '11 at 7:24

Ctools has a nice modal functionality that is easy to use, and doesn't need you to manually add any depended JavaScript code.


There is Dialog API for Drupal 6, and Drupal 7 (although only the development snapshot for Drupal 7 is visible in the project page). This module contains sub-module Dialog Comment.

For Drupal 7, as I can see, there are some problems with modules for popup dialogues.

  • Is there any jquery plugin to which I pass the form id and then it shows that form in a popup?
    – Ahmad
    Aug 24 '11 at 3:08

If you want to do it in a fancy non-technical way use Beauty Tips module.

if you need help here is a good video on this topic.


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