Quip: Get the comment count for a thread
Posted by garryn on Feb 3, 2010 | Filed under: MODx Revolution
Note: Since writing this post, Quip has been updated and the latest versions ship with a QuipComment snippet.
Quip is the third-party component available for MODx Revolution to allow commenting on resources. For example, this blog uses Quip to allow commenting on blog posts.
But, say you want to get the comment count for a particular thread elsewhere within your site - how would you do it? For the solution, read on.
Here is a snippet that will grab the comment count for a particular Quip thread, it can be called anywhere on the site as long as you know the thread ID that you want to get the comment count for. The snippet accepts one parameter:
- thread: The thread ID that you want to receive the comment count for.
And, here is the snippet:
require_once $modx->getOption('core_path').'components/quip/model/quip/quip.class.php';
if (!isset($scriptProperties['context'])) $scriptProperties['context'] = 'web';
$quip = new Quip($modx,$scriptProperties);
return $modx->getCount('quipComment', array('thread' => $scriptProperties['thread']));
And, an example call:
[[!getCommentCount? &thread=`blog_[[*id]]`]]