How can I display comments/comment form with a custom module? I have created a module which returns a render array via page callback in hook_menu. The render array contains several arrays that render markup and tables (and data from a particualr node: passed in by a wildcard in the submitted URL). At the bottom of the rendered page I would like the comments and the comments form to be displayed.  My plan is to get the comments via a database query, put them into an array and add them to the render array. For the comments form I was going to use the following code:

    $comment = new stdClass;
    $comment -&gt; nid = $nid;
    $form = drupal_get_form('comment_form', $comment);
    return $form;


How do I append this to my page callback function so that my table/markup render arrays and comments/comments form appear on the outputted page?

Thanks. Hope this makes sense. I'm open to changing my plan if you think there's a better approach.
Solution

To append the comments form, add this to your render array:

$foo = array(
    'comments' =&gt; drupal_get_form('comment_form', $comment),
),


Add this, just above your render array:

$comment = new stdClass;
$comment -&gt; nid = $nid;