Hi All,

I have the NID of the node and the CID of the comment. I can't seem to find an API function to let me print out the comment that is related to these two. Can someone point me in the right direction?

I can do a load_node, but how do I actually print it out?

Thanks,

Comments

RedRaven-1’s picture

So thus far I have:

function MYTHEME_preprocess_node_MYNODE(&$variables) {
	$node = menu_get_object();
	if (!empty($node) && !empty($node->nid))
	//if ((arg(0) == 'node') && is_numeric(arg(1))) 
	{
   		$result = db_query_range('SELECT c.cid, c.nid
  		FROM {comment} c WHERE c.nid = :cid ORDER BY c.cid DESC', 0, 3, array(':cid' => arg(1)));
	
		$i = 0;		
		foreach ($result as $record) {
 	 		$variables['NewComments'][$i] = $record -> cid;	 		
			$i++;
		}
	}
	
	else {
		$variables['errorCheck'] = t('nope fail');
	}
}

In my template.php hook_node, which gives me the CIDs I'm looking for.

Then in my node.tpl I have:

$theComments = comment_load_multiple($cids = $NewComments);

Which works nicely to load my comments (I checked this with dsm and the array is there), I just can't get them to show up on the page. What am I doing wrong?