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
Comment #1
rjbrown99 commentedI'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?
Comment #2
Hunabku commentedhow 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 . . .
Comment #3
Hunabku commentedTo 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:
Comment #4
Hunabku commentedBump - help please - seems like a maintainer could easily provide at least a little guidance here based on post #3.
Comment #5
neochief commentedJust 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.
Comment #6
Hunabku commentedThanks 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));Comment #7
neochief commentedThat is right.
Comment #8
Hunabku commentedGreat it works! I just went with:
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:
Here is your function code for reference:
Comment #9
Hunabku commentedOops 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:
Any ideas?
Comment #10
muthuraman-s commentedAjax 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.
Comment #11
qzmenkoIssue is closed because 6.x version is unsupported. Feel free to open new issue for 7.x or 8.x versions of module.