Website Comments - Active Comments List?

2 posts by 2 authors in: Forums > CMS Builder: Plugins & Add-ons
Last Post: May 11, 2015   (RSS)

By gregThomas - May 11, 2015

Hey Perch,

You'd need to use a getRecords call to get the required records from the database:

  // load comments
  list($comments, $commentsMetaData) = getRecords(array(
    'tableName'     => '_wsc_comments',
    'orderBy'       => 'createdDate DESC',
    'limit'         => 50,
    'allowSearch'   => false,
  ));

So the statement above would retrieve the 50 newest comments from the comments section. You could then display each comment like this:

<html>
  <body>
    <ul>
      <?php foreach($comments as $comment): ?>
        <?php $schema = loadSchema($comment['tableOrTag']); ?>
        <li>
           <a href="<?php echo $schema['_detailPage']; ?>?num=<?php echo $comment['recordNum']; ?>"><?php echo $comment['comment']; ?></a>
        </li>
      <?php endforeach; ?>
    </ul>
  </body>
</html>

So this code will get the appropriate schema file and get its detail page link, then display it along with the comments record number.

Cheers,

Greg

Greg Thomas







PHP Programmer - interactivetools.com