Outputting recent comments in a different part of the node I have created a custom node, and at the bottom of this node I would like to show the latest three comments made on that node. I have added the code below to my template.php, and then loop through the array to get the data in my node:

if ((arg(0) == 'node') &amp;&amp; is_numeric(arg(1))) 
{
    $result = db_query_range('SELECT c.cid, c.nid, c.subject, c.name
    FROM {comment} c WHERE c.nid = :cid ORDER BY c.cid DESC', 0, 3, array(':cid' =&gt; arg(1)));

    $i = 0;     
    foreach ($result as $record) {
        $variables['NewComments']['NewSubject'][$i] = $record -&gt; subject;
        $variables['NewComments']['NewName'][$i] = $record -&gt; name;
        $i++;
    }
}

else {
    $variables['errorCheck'] = t('nope fail');
}


However, I am having trouble outputting this into the node.tpl. Is there an easy way to do this, or should I try something else to tackle this issue?

Thanks
You can do that using views.







Then you can either add this view as a block or you can use http://api.drupal.org/api/views/views.module/function/views_embed_view/7 in node.tpl.php