Jump to content

Recommended Posts

Posted

Hi there!

I need to gather a list of all comments, regardless of the parent page of each comment. Is there a global $comments object, which can do this? Something like:

foreach($comments->find('sort=-created') as $comment) {
// show comment
}

I did not find anything similar in the forums. Can someone help me?

Posted

I came up with a pretty "close-to-the-metal" solution. Not perfect, but seems to work:

$comments = $database->query('SELECT * FROM field_comments ORDER BY created DESC');
foreach($comments as $c) {
  // $c is an array with raw database values of those comments
}

 

Posted

Not tested, but you could search by template(s) and doing something like:

<?php

$replies = $pages->find("template=your_template");
	foreach ($repliess as $reply ) {
		foreach ($reply->comments as $message) {
			# code...
		}
	}

?>

 

Posted

@louisstephens Thank you for your thoughts!

Sure, I could use these "nested" queries to gather a "global comments array", which I would to sort by "created" afterwards. But these are too many steps and seems not very performance efficient.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...