Hey There alik,
Thanks for the snippet, everything worked great (I forgot to use my own database prefix_ at first). I also wnated to include the poster’s name and tried to do that myself, but as you can see I don’t know any php.
The name is kept in a different place called: ssb_jot_fields. Is it possible to bring in the names and link them with the comments? Here was my feeble attempt!:
<?php
/* scheme for LatestComments snippet */
$count = 3; // how many latest comments
// fetch latest comments
$results = $modx->db->select('uparent,title,content,createdon', 'ssb_jot_content', 'published=1', 'createdon DESC', $count);
// fetch poster's name
$results = $modx->db->select('content', 'ssb_jot_fields', $count);
// render output
$output = '';
while ($row = mysql_fetch_array($results, MYSQL_ASSOC)) {
// now use $row['uparent'], $row['title'], $row['content'], $row['createdon']
// for building your list of latest comments
// $row['uparent'] -> id of the doc that the comment is attached to
// $row['title'] -> comment's title
// $row['content'] -> name of commenter
// ...
// for example, comment's title as a link to its article
$output .= '<div class="jot-user">' . $row['content'] . ' SAYS:</div><div class="jot-message"><a href="[~' . $row['uparent'] . '~]">' . $row['content'] . '</a></div>';
}
return $output;
?>