<?php
$discuss = $modx->getService('discuss','Discuss',$modx->getOption('discuss.core_path',null,$modx->getOption('core_path').'components/discuss/').'model/discuss/');
if (!($discuss instanceof Discuss)) return true;
$c = $modx->newQuery('disPost');
$c->where(array('private' => 0));
$c->limit(10);
$c->orderby('createdon', 'DESC');
$posts = $modx->getCollection('disPost', $c);
foreach ($posts as $post) {
$temp = $post->toArray();
$temp['url'] = $post->getUrl();
// call chunks or what you want
$out[] = $modx->getChunk('rowTpl', $temp);
}
return implode("\n", $out);This question has been answered by sottwell. See the first response.
<?php
$discuss = $modx->getService('discuss','Discuss',$modx->getOption('discuss.core_path',null,$modx->getOption('core_path').'components/discuss/').'model/discuss/');
if (!($discuss instanceof Discuss)) return true;
$c = $modx->newQuery('disPost');
$c->where(array('private' => 0));
$c->limit(10);
$c->sortby('createdon', 'DESC');
//echo the generated sql
$c->prepare();echo $c->toSql();
if ($posts = $modx->getCollection('disPost', $c)){
foreach ($posts as $post) {
$temp = $post->toArray();
// print the row-array
print_r($temp);
$temp['url'] = $post->getUrl();
// call chunks or what you want
$out[] = $modx->getChunk('rowTpl', $temp);
}
return implode("\n", $out);
}
return 'nothing was found'; SELECT `disPost`.`id` AS `disPost_id`, `disPost`.`board` AS `disPost_board`, `disPost`.`thread` AS `disPost_thread`, `disPost`.`parent` AS `disPost_parent`, `disPost`.`title` AS `disPost_title`, `disPost`.`message` AS `disPost_message`, `disPost`.`author` AS `disPost_author`, `disPost`.`createdon` AS `disPost_createdon`, `disPost`.`editedby` AS `disPost_editedby`, `disPost`.`editedon` AS `disPost_editedon`, `disPost`.`icon` AS `disPost_icon`, `disPost`.`allow_replies` AS `disPost_allow_replies`, `disPost`.`rank` AS `disPost_rank`, `disPost`.`ip` AS `disPost_ip`, `disPost`.`integrated_id` AS `disPost_integrated_id`, `disPost`.`depth` AS `disPost_depth`, `disPost`.`answer` AS `disPost_answer` FROM `modx_discuss_posts` AS `disPost` WHERE `disPost`.`private` = '0' ORDER BY createdon DESC LIMIT 10 nothing was found