ak112358
ak112358

Reputation: 713

Drupal 7 $comment object enumeration

I need a listing of all of the members of the (or any instance of) $comment object. What's the best way to generate this? Is there a place in the Drupal source code where the definition is easy to find (I looked, but came up dry)?

Something like this is for the $node object: http://drupal.org/node/49768 (only without the descriptions of course).

Upvotes: 1

Views: 894

Answers (3)

James
James

Reputation: 661

  1. get Drupal for Firebug - http://drupal.org/project/drupalforfirebug - also contains a link to the Drupal for Firebug Firefox extension that works with Firebug. This will save you a lot of pain when you need to dump data. You simply write somewhere into the code firep($someVar) and the dump will be displayed in the appropriate Firebug pane.

  2. Go to your theme, and find the appropriate template for comments - comment.tpl.php (if you're using the tpl.php type theme engine). This would be the right spot for you to try "dumping" the comment variable - insert at the top firep($comment); this will show you the full comment object.

Here's a dump from a Drupal 6 install, Drupal 7 may be different:

stdClass Object
(
[cid] => 1676
[pid] => 0
[nid] => 1672
[subject] => Comment Body
[comment] =>

Comment Body


[format] => 1
[timestamp] => 1300904186
[name] => admin
[mail] =>
[homepage] =>
[uid] => 1
[registered_name] => admin
[signature] =>
[signature_format] => 0
[picture] => sites/default/files/pictures/picture-1.jpg
[data] => a:7:{s:17:"messaging_default";s:4:"mail";s:6:"preset";s:18:"atrium_user_simple";s:14:"picture_delete";s:0:"";s:14:"picture_upload";s:0:"";s:13:"form_build_id";s:37:"form-5ab3ec10bc31bce9da52e443b0fa0651";s:27:"notifications_send_interval";s:1:"0";s:16:"comment_settings";s:0:"";}
[thread] => 01/
[status] => 0
[messaging_default] => mail
[preset] => atrium_user_simple
[picture_delete] =>
[picture_upload] =>
[form_build_id] => form-5ab3ec10bc31bce9da52e443b0fa0651
[notifications_send_interval] => 0
[comment_settings] =>
[depth] => 0
[new] => 0
)

Upvotes: 1

berkes
berkes

Reputation: 27543

Try comment_load_multiple()

<?php
  $conditions = array("pid" => $comment_you_want_the_children_of->id);
  comment_load_multiple(array(), $conditions);
?>

Upvotes: 1

Matt V.
Matt V.

Reputation: 9809

You could send $comment through the Devel module's dpm() function:

dpm($comment); 

Upvotes: 2

Related Questions