Adding class="popups-form" to the 'Add New Comment' link is easy. The problem is that it doesn't return just the form - it returns the item parents as well which is ugly and unnecessary. I'm assuming all that is needed to be done is to create a page that returns just the right comment form which seems pretty easy. Before I attack the comment module I thought I would check to see if anyone has done it already or perhaps an easier solution.

Thanks

Awesome module by the way..

Comments

mstef’s picture

Status: Active » Fixed
function helper_menu_alter(&$items) {
	$items['comment/reply/%node']['page callback'] = 'helper_show_comment';
	$items['comment/reply/%node']['file'] = '';
}
function helper_show_comment($node, $pid = NULL) {
	return comment_form_box(array('pid' => $pid, 'nid' => $node->nid), NULL);	
}
vertazzar’s picture

thanks for info, im going to use that override as well.

mstef’s picture

No problem - just don't forget to select the comments links
'node/*' = array(
'a[href^=/comment/]',
),

Also, make sure you empty out the entire cache. Had some problems with the alter hooks.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Oghnia’s picture

I seriously don't get what was done here, can someone please elaborate :)

thanks

Oghnia’s picture

Status: Closed (fixed) » Active

sorry forgot to open it

mstef’s picture

@Oghnia

If you want to enable popup comments, create a helper module and include the two functions from comment #1. then add the code in #3 to the modules hook_popups.

v8powerage’s picture

Version: 6.x-2.x-dev » 6.x-2.0-alpha5

in popups_comment.module:

function popups_comment_popups() {
    return array(
    'node/*' => array(
	'.links a:contains('. t('Edit') .')'=> array( 
        'updateMethod:reload',
      ),
    ),
  );
}

in popups_comment.info:

name = Popups: Comment Edit Link
description = Uses the Popups API to add popups to comment edit links.
package = User interface
core = 6.x
dependencies[] = popups

Put those two files into folder named popups_comment in modules directory, go to admin/build/modules enable, then go to /admin/settings/performance and clear cache.

sirkitree’s picture

@see #508830: Duplicate attachment of Wysiwyg behavior with Popups for the problem with editors like tinymce or bueditor.

darsic’s picture

How can i add popup class to print $links; ?

obrienmd’s picture

I must be a fool - I still don't understand. It's easy for me to put the functions from #1 into a custom module, but I'm not sure what is meant by "then add the code in #3 to the modules hook_popups."

Is anyone willing to spell that last part out a little more extensively?

v8powerage’s picture

I pasted code at #8. Just create file in text editor and save it as module.

obrienmd’s picture

Works great, thanks so much!

RedTop’s picture

Version: 6.x-2.0-alpha5 » 6.x-2.x-dev

Unfortunately the module in #8 doesn't work for me. After adding the popups_comment module I get a syntax error:

Parse error: syntax error, unexpected ';', expecting ')' in C:\Program Files\wamp\www\drupal\sites\default\modules\popups_comment\popups_comment.module on line 8

Tried adding an extra ")" and this "solves" the syntax error, but no popups for me after clicking "add new comment". Obviously I am no PHP coder... :P

I am using a WYSIWYG client side editor (FCKeditor).

v8powerage’s picture

Version: 6.x-2.0-alpha5 » 6.x-2.x-dev

Sorry, my fault missed one ), now it's ok.

obrienmd’s picture

Hrm - I spoke too soon... I've added the modules as instructed in #8, but hitting a comment link in a node does not bring up a popup, just opens up a new page w/ comment form on the bottom. The link seems to satisfy the requirements (in the "links" area), any ideas on debugging?

I see "('. t('Edit') .')" in your function, but not really sure what this means? I don't see "Edit" anywhere in the tag or text of my comment links...

obrienmd’s picture

I am an idiot - it was looking for the string "Edit", I just changed to something else that was in the link's text, and it worked great. Thanks!

RedTop’s picture

Could you please elaborate obrienmd? I now have:

<?php
function popups_comment_popups() {
    return array(
    'node/*' => array(
    '.links a:contains('. t('comment') .')'=> array(
        'updateMethod:reload',
      ),
    ),
  );
}
?>

(replaced Edit with comment), but that doesn't do it for me.

v8powerage’s picture

The code was for editing comment, to add reply feature, replace 'Edit' with 'Reply'.

RedTop’s picture

Thanks, I had tried that before but was under the impression it didn't work. Now I know why: it only works for comment links on the actual node itself, not the links below the teaser (as would be the case with blogentries on the frontpage).

I am going to tinker with it a little more. See if this may be a good opportunity to learn PHP. :P

v8powerage’s picture

RedTop - for the comment reply link which is in other place, than node try this:

function popups_comment_popups() {
    return array(
    '*' => array(
	'a[href*=comment/reply/]',
    ),
  );
}
RedTop’s picture

Thanks, works like a charm. :)

RedTop’s picture

Status: Active » Needs review

Step-by-step:

In your sites/YOURSITE/modules directory create a folder 'popups_comment'. In this folder create two files with the code pasted below:

file: popups_comment.module

<?php
function popups_comment_popups() {
 return array(
  '*' => array(
   'a[href*=comment/reply/]',
  ),
 );
}

function popups_comment_menu_alter(&$items) {
 $items['comment/reply/%node']['page callback'] = 'helper_show_comment';
 $items['comment/reply/%node']['file'] = '';
}

function helper_show_comment($node, $pid = NULL) {
 return comment_form_box(array('pid' => $pid, 'nid' => $node->nid), NULL);
}

?>

file: popups_comment.info

;
name = Popups: Comment Edit Link 
description = Uses the Popups API to add popups to comment edit links.
package = User interface
core = 6.x
dependencies[] = popups

version = "6.x-2.x-dev"
core = "6.x"
project = "popups"

Enable the new module and clear your cache using administer > site configuration > performance

Thanks to Shaman for the code. :)

RedTop’s picture

Status: Active » Needs review

I'm busy developing a module to add popup support to comment forms. It is a first attempt at Drupal Development and a bit of PHP. This is what I have so far:

popups_comment.module

<?php
// $Id$:

/**
 * @file
 * Turns comment forms into popups using Popups API.
 *
 * Displays a popup when user clicks on a comment add, edit, delete or reply link.
 * Modifies the popup page so that it shows only the textarea, submit putton and preview button.
 */


/**
 * Implementation of hook_popups
 * Select link locations to turn into popup form
 *
 * Only use comment form popups when enabled - needs work!
 */
switch (variable_get('popups_comment_enable', 1)) {

 case 0:
 function popups_comment_menu_alter(&$items) {
  $items['admin/settings/popups']['page arguments'] = array('popups_comment_admin');
  $items['admin/settings/popups']['file'] = 'popups_comment.admin.inc';
  $items['admin/settings/popups']['file path'] = 'sites/default/modules/popups_comment';
 }
 break;

 
 case 1:
 function popups_comment_popups() {
  return array(
   '*' => array(
    'a[href*=comment/reply/]',
    'a[href*=comment/edit/]',
    'a[href*=comment/delete/]',
   ),
  );
 }
 
 
/**
 * Remove body text from popup page, change title and add popups_comment setting to popus admin settings page
 */
 function popups_comment_menu_alter(&$items) {
  $items['comment/reply/%node']['title'] = 'Add a comment';
  $items['comment/reply/%node']['page callback'] = 'helper_show_comment';
  $items['comment/reply/%node']['file'] = '';
  
  $items['admin/settings/popups']['page arguments'] = array('popups_comment_admin');
  $items['admin/settings/popups']['file'] = 'popups_comment.admin.inc';
  $items['admin/settings/popups']['file path'] = 'sites/default/modules/popups_comment';
 }
 
 function helper_show_comment($node, $pid = NULL) {
  return comment_form_box(array('pid' => $pid, 'nid' => $node->nid), NULL);
 }
 
 
 /**
 * Remove author, homepage and input filter from comment form
 */
 function popups_comment_form_alter(&$form, &$form_state, $form_id) {
  if($form_id == 'comment_form') {
   unset($form['admin']);
   unset($form['_author']);
   unset($form['_homepage']);
   unset($form['homepage']);

   
   // This completely removes the input format form, but breaks the (WYSIWYG) functionality as well...
   unset($form['comment_filter']['format']);
 
  }
 }
 break;

} //end switch

?> // here for syntax highlighting

popups_comment.info

; $Id$:
name = Popups: comment edit link 
description = Uses the popups API to add popups to comment links.
package = User interface
core = 6.x
dependencies[] = popups

version = "6.x-2.x-dev"
core = "6.x"
project = "popups"

popups_comment.admin.inc

<?php
// $Id$

/**
 * @file
 *
 * Administration page callbacks for the popups_comment module.
 */

/**
 * Form builder. Rewrite popups admin settings page to include popups_comment setting
 *
 * @ingroup forms
 * @see system_settings_form().
 */
    
 
function popups_comment_admin() {
  $form = array();

/**
 * First repeat the popups module settings - Should be dynamic
 */
  $form['popups_always_scan'] = array(
    '#type' => 'checkbox',
    '#title' => t('Scan all pages for popup links.'),
    '#default_value' => variable_get('popups_always_scan', 0),
  );
  $form['popups_autoclose_final_message'] = array(
    '#type' => 'checkbox',
    '#title' => t('Automatically close final confirmation messages.'),
    '#default_value' => variable_get('popups_autoclose_final_message', 1),
  );

  // Retrieve all available skins, forcing the registry to refresh.
  $skins['Unskinned'] = array();
  $skins += popups_skins(TRUE);
  
  $skin_options = drupal_map_assoc(array_keys($skins));
  $form['popups_skins'] = array(
    '#type' => 'fieldset',
    '#title' => t('Skins'),
    '#description' => t('Choose a skin from the list. After you save, click !here to test it out.', array('!here' => l('here', 'user', array('attributes' => array('class' => 'popups'))))),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
  );
  $form['popups_skins']['popups_skin'] = array(
    '#type' => 'radios',
    '#title' => t('Available skins'),
    '#default_value' => variable_get('popups_skin', 'Basic'),
    '#options' => $skin_options,
  );

/**
 * Next add popups_comment setting
 */
  $form['popups_comment_enable'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable popups for comment forms.'),
    '#default_value' => variable_get('popups_comment_enable', 1),
    '#description' => t('Clear cache after changing! Site configuration >> Performance, click Clear cached data button.'),
  );

  return system_settings_form($form);
}
?> // here for syntax highlighting

It works, but there are some glitches that I would like to fix but don't know how:

1) After enabling or disabling the functionality at the popups admin settings page one has to manually clear the cache and rebuild the menus before the changes can be noticed. How can I prevent this?
2) popups.admin.inc for now repeats the admin settings form code from popups.module. Is there a way I can simply call the form as defines in popups.module? This prevents having to update popups_comment.admin.inc everytime the popups settings page is changed.
3) When previewing a comment the parent node/comment is shown below the form. I would like to remove this. How do I do that? I assume I have to use hook_menu_alter.

RedTop’s picture

Status: Needs review » Active

changed status.

Caderial’s picture

I have implemented this module for comment pop up, but when ever i submit the comment, the page reloads within the popup opposed to closing the pop up and reloading the page beneath.

How can i force the Pop up to close & reload the page with the new comments when i click the save (submit) button in the comment form pop up?

when i submit comments normally from a users blog page(without pop up), it takes me to the node of the specific blog post instead of back to the blog page i have created in views. I need to redirect the user back to the Blog page not the node of the post they commented on. I think this might be why the PopUp comments is keeping the pop up window open and loading the Node with its comments in it. Is there some code i can put into the popups_comment.module that will redirect the user back to the blog page and not he specific posts node?

Stranger still If the Post already has comments on it, and i Use the "reply" button under an existing comment, the pop up form comes ups fine, i fill in the comment reply, and submit. now it does its loading thing and closes the pop up and reloads the page below it fine. This is the functionality i want on the Add a comment form pop up as well.

Its strange that they act differently, seeing as how they are both pulling up the same form in the pop up...

Fairly new to this so any help would be appreciated.

My popups_comment.module

<?php
function popups_comment_popups() {
return array(
  '*' => array(
   'a[href*=comment/reply/]',
   'updateMethod:reload',
  ),
);
}

function popups_comment_menu_alter(&$items) {
$items['comment/reply/%node']['page callback'] = 'helper_show_comment';
$items['comment/reply/%node']['file'] = '';
}

function helper_show_comment($node, $pid = NULL) {
return comment_form_box(array('pid' => $pid, 'nid' => $node->nid), NULL);
}

?>

My popups_comment.info

;
name = Popups: Comment Edit Link 
description = Uses the Popups API to add popups to comment edit links.
package = User interface
core = 6.x
dependencies[] = popups

version = "6.x-2.x-dev"
core = "6.x"
project = "popups"
Caderial’s picture

Title: Adding Commenting Support » Disable Redirect within Pop up?
Status: Needs review » Active

maybe implement a .forceReturn ??

ruinze’s picture

subscribed