ajax comment refresh module, which hook to take?

rekcor - August 24, 2009 - 11:26

Currently I am developing a module which updates the comments for a node in realtime using AJAX.

The good news: my alpha version works! Still quite some things to do, e.g. dealing with paging issues.

The bad news aka my question: I have to insert some Javascript on the page to handle the AJAX requests, but which hook should I use for that? Currently I am using hook_comment, which works. The disadvantage: it is called for each comment, so e.g. in PHP

drupal_add_js(array('commentsAjaxRefresh' => array("json_url"=>$json_url)), 'setting');

actually results in an array Drupal.settings.commentsAjaxRefresh.json_url (in stead of an integer), with a length equal to the number of comments. The hook_view does not seem to work (no js is inserted) and besides that: not every node will have comments.

So what node should I take?

P.S. Just out of curiosity: is anyone besides me interested in this module?

Ajax Module

homerzzz - August 25, 2009 - 01:32

Yes, I'm interested in the module. I've tried using the ajax_comments module, but it doesn't quite fit my needs.

Looking forward to the first release.

@homerzzz: see

rekcor - August 26, 2009 - 13:54

@homerzzz: see http://drupal.org/node/401288#comment-1971896

The answer of this question: hook_nodeapi did the trick.

Yes this will be an useful module.

kaakuu - August 26, 2009 - 13:58

Yes this will be an useful module.
This should be extended as an admin-configurable option to all lists (like those generated by views)
apart from comments. An audio alert by ajax whenever there is something new (on-offable) will be great too.

Is there a downloadable tar that can be tested ?

See the link above for the

rekcor - August 26, 2009 - 15:04

See the link above for the zip. It is in alpha state, so take care.

This should be extended as an admin-configurable option to all lists (like those generated by views)
apart from comments.

But would that not lead to an annoying user experience? E.g. you are reading a web page, and suddenly something changes while reading...

In list pages this type of

kaakuu - August 26, 2009 - 16:14

In list pages this type of ajax behavior adds a topic added to the top of the list. Without disturbing what is being read. For example, see Gmail.

I understand, but first I

rekcor - August 27, 2009 - 06:21

I understand, but first I want to focus on the comments (if you don't mind :)

 
 

Drupal is a registered trademark of Dries Buytaert.