Skip to content

Instantly share code, notes, and snippets.

@modxws
Created February 21, 2013 18:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save modxws/5007070 to your computer and use it in GitHub Desktop.
Save modxws/5007070 to your computer and use it in GitHub Desktop.
<?php
/* параметры:
// &limit по умолчанию 5
// &cls по умолчанию 'tpl.latest.comments'
// &tpl по умолчанию 'quip-latest-comment'
*/
$output = '';
$limit = !empty($limit)?$limit:5;
$tpl = !empty($tpl)?$tpl:'tpl.latest.comments';
$cls = !empty($tpl)?$cls:'quip-latest-comment';
$siteUrl='.24-org.org';
$modx->addPackage('quip', MODX_CORE_PATH . 'components/quip/model/', 'modx_');
$q = $modx->newQuery('quipComment');
$q->select('thread,body,existing_params,createdon,name');
$q->where(array(
'quipComment.deleted' => false,
'quipComment.approved' => true,
));
$q->sortby('createdon','DESC');
$q->limit($limit);
$q->prepare();
$q->stmt->execute();
$res = $q->stmt->fetchAll(PDO::FETCH_ASSOC);
foreach ($res as $v) {
$pos = strpos($v['thread'],'-');
if ($pos !== false) {
$str = substr($v['thread'],0,$pos);
$firm = substr($v['thread'],$pos+1);
};
$firmId = json_decode($v['existing_params'], true);
$url = 'http://'.$str.$siteUrl . '/detail/' . $firmId['firmid'];
$modx->setPlaceholder('url', $url);
$modx->setPlaceholder('firm',$firm);
$modx->setPlaceholder('createdon',$v['createdon']);
$modx->setPlaceholder('name',$v['name']);
$modx->setPlaceholder('cls',$cls);
$modx->setPlaceholder('body',$v['body']);
$output .= $modx->getChunk($tpl, $v);
};
return $output;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment