I made it thru a gotcha on the path to making comment_render() work with Ajax Comments from within a node template. One has to be sure that the node, which is displaying the comments culled from comment_render, has a comment setting of "Read" or Read/Write". Go figure.

In my user pages i DO NOT need to add/display comments for the user - rather i need to display comments from another node type - hence comment_render().

However with Content Profile hooking itself into the user page, Ajax Comments does not activate for the content profile type. - PS i'm issuing comment_render() via an actual user page "user/username" not a content profile node.

Comments

rjbrown99’s picture

Priority: Major » Normal

I'm not sure I am following - how are you displaying comments from one node type on a different node type? Can you be more specific as to how someone would go about reproducing this behavior?

Hunabku’s picture

how are you displaying comments from one node type on a different node type?

To be more clear:

I display comments from a different node type thru a "print (comment_render($node));" inside a node template. Where $node is a different node type. If the comment permissions of the parent node (the one belonging to the template type) are not Read or Read/Write then the comments from the different node type are not ajaxified. I reproduced this in a very close to clean install.

On my content_profile moded user page, i can't get comment_render() comments ajaxified at all and there are of course no comment permissions for user objects in d6 core. I currently display comments on the user page by using a profile node template that embeds a view which has a corresponding views table template. Within that template, "print (comment_render($node_loaded);" is called multiple times via a table row loop that iteratively loads nodes. In this way i'm displaying multiple sets of comments from nodes of a different type than the profile type.

I could try and NOT use views. Then i'd build my own query and a looped comment_render() inside a custom module function - i'd call the function from my profile node template. But it doesn't look like that would solve the problem since AJAX Comments seems untriggered by the cck profile type via the user page ie users/uid.

thanks for your time on this and please let me know if you need additional info . . .

Hunabku’s picture

Priority: Normal » Major

To really simplify the problem . . . Ajax Comments does not work on user profile page - i.e. comment_render() is not ajaxified when it is called from within the "user-profile.tpl.php" template:

$node_loaded = node_load(4);
print (comment_render($node_loaded));
Hunabku’s picture

Bump - help please - seems like a maintainer could easily provide at least a little guidance here based on post #3.

neochief’s picture

Just find in the code where and how JS files are attached and do the same somewhere close to your loading actions. There's no way o hook in comment_render, so AC attaches it's scripts somewhere higher, I don't remember exactly.

Hunabku’s picture

Thanks neochief. Are you suggesting that i copy the code from your "ajax_comments.module" that attaches JS files and paste it right before: print (comment_render($node_loaded));

neochief’s picture

That is right.

Hunabku’s picture

Great it works! I just went with:

    ajax_comments_post_comment_render($node_loaded, NULL);
    print (comment_render($node_loaded));

I called your function (ajax_comments_post_comment_render) that loads the JS files as i noted that there isn't much extra code in it and executing that code (twice?) didn't cause any problems. Can you see any advantages of executing the whole function or should i just take out the lines that load the js files?

I tried taking out and inserting following but it didn't work:

    $path = drupal_get_path('module', 'ajax_comments');
    drupal_add_js('misc/jquery.form.js');
    drupal_add_js($path .'/ajax_comments.js', 'module');
    print (comment_render($node_loaded));

Here is your function code for reference:

/**
 * Implementation of hook_post_comment_render().
 * Add ajax comments scripts on the page after comments being rendered.
 * @see comment_bonus_api_comment_render()
 */
function ajax_comments_post_comment_render($node, $cid) {
  $path = drupal_get_path('module', 'ajax_comments');
  drupal_add_css($path .'/ajax_comments.css');

  // Language settings
  $mode = variable_get('language_negotiation', LANGUAGE_NEGOTIATION_NONE);
  $languages = language_list('enabled');
  $languages = $languages[1];

  drupal_add_js('misc/jquery.form.js');
  drupal_add_js($path .'/ajax_comments.js', 'module');
  drupal_add_js(array(
    'language_mode' => $mode,
    'language_list' => $languages,
    'clean_url' => variable_get('clean_url', 0),
    'comment_preview_required' => variable_get('comment_preview_'. $node->type, COMMENT_PREVIEW_REQUIRED) == COMMENT_PREVIEW_REQUIRED,
    'ajax_comments_rows_in_reply' => variable_get('ajax_comments_reply_row_count', 3),
    'ajax_comments_rows_default' => variable_get('ajax_comments_default_row_count', 5),
    'ajax_comments_always_expand_form' => variable_get('ajax_comments_always_expand_form', TRUE),
    'ajax_comments_blink_new' => variable_get('ajax_comments_blink_new', TRUE),
    'comment_bonus_api_fold_comments' => variable_get('comment_bonus_api_fold_comments', FALSE),
    'ajax_comments_nid' => $node->nid,
  ), 'setting');
}
Hunabku’s picture

Oops not so fast. If I have multiple comment renders (for different nodes - same type) on the same page, then only the first one will get ajaxified.

This happens wether or not I do the following drupal_add_js for each comment render node:

 drupal_add_js(array(
    'language_mode' => $mode,
    'language_list' => $la . . . . . .
    . . . . . . .

Any ideas?

muthuraman-s’s picture

Ajax comments not working on the views pages. I cannot able to render the ajax comments in views page in Drupal 6.

FYI
I have also noticed that ajax comment.js file not included in the views pages and if i include the file in views template also . Reply and save comments get loaded and going to seperate page. Delete action is working on ajax method.

Kindly guide me on this.

qzmenko’s picture

Issue summary: View changes
Status: Active » Closed (outdated)

Issue is closed because 6.x version is unsupported. Feel free to open new issue for 7.x or 8.x versions of module.