Both comment.load and comment.loadNodeComments currently return the raw column data from the database query in _comment_load(). Contrib modules can add information to the comment object inside hook_comment's "view" operation, however this hook isn't currently being called by either of the Services API functions.
Attached is a patch that modifies both Services API functions to pass each comment through hook_comment prior to returning it.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | comment_service-invoke-01.patch | 833 bytes | smokris |
| comment_service-invoke-00.patch | 783 bytes | smokris |
Comments
Comment #2
smokris(Fix relative directory in patch.)
Comment #3
skyredwanghmmm. This is a good question. Comment services just pass the information to Drupal comment API. I noticed that comment_save() invoke contrib modules, but _comment_load() doesn't. see http://api.drupal.org/api/function/_comment_load/6
I would mark this as 'by design'
Comment #4
mradcliffeWhy would you mark this 'by design'? It seems to be more of a feature request to allow comments to be modified by contrib modules. Why would you limit the comment service to just what's in core? That doesn't make any sense to me.
I think the patch needs work, and should be bumped to 6.x-3.x-dev for development as a feature request.
For instance the old way returns an array of comments, but the patch just returns one comment. The patch should maintain the API. I'll try writing a patch for the next version.
Comment #5
kylebrowning commentedComment #6
skyredwangServices is only responsible for exposing existing core APIs in a standard way. Services module will not create "new" functions. If the Drupal core doesn't provide the comment functions that you need, you can write your own custom services. Or, you can file feature request to Drupal Core. This is marked as "by design".
Comment #6.0
silverwing commentedclosing comments due to spam
Comment #6.1
ionut65 commentedttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt
Comment #6.2
silverwing commentedCopy of the revision from March 6, 2012 - 00:07.