Hello, I use the ctools comment content_type in my panels 3 pages, and I think that an improvement of the query in the ctools_comment_render method of the node_comment.inc file can help when working with threaded comment :

the query

$query = 'SELECT c.cid as cid, c.pid, c.nid, c.subject, c.comment, c.format, c.timestamp, c.name, c.mail, c.homepage, u.uid, u.name AS registered_name, u.picture, u.data, c.thread, c.status FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid 
WHERE c.nid = %d';

can be replaced by this one :

$query='SELECT c.cid AS cid, c.pid, c.nid, c.subject, c.comment, c.format, c.timestamp, c.name, c.mail, c.homepage, u.uid, u.name AS registered_name, u.picture, u.data, c.thread, c.status, parent_user.uid as parent_uid, parent_user.data as parent_data,parent_user.name as parent_name, parent_user.picture as parent_picture
FROM {comments} c
INNER JOIN {users} u ON c.uid = u.uid
LEFT OUTER JOIN {comments} parent ON c.pid = parent.cid
LEFT OUTER JOIN {users} parent_user ON parent.uid = parent_user.uid WHERE c.nid =%d';

which adds the additional fields in the $comment variable :

  • $comment->parent_uid
  • $comment->parent_name
  • $comment->parent_picture
  • $comment->parent_data

It would greatly help when theming threaded comment, and allow to display the username of the user we are responding to and his avatar.

I have included the field data because used wisely this field can helpin some circumstances (in my case I store in it a nickname != from the default drupal username for example)

Comments

merlinofchaos’s picture

Status: Active » Fixed

Sure, that looks reasonable. Committed, with style fixes.

Status: Fixed » Closed (fixed)

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