// get all documents
$order['componentName'] = 'date';
$order['direction'] = DCDescending;
$options['rowOrder'] = array($order);
$subset['startIndex'] = 20;
$subset['maxCount'] = 10000;
$options['rowSubset'] = $subset;
//$subset['maxCount'] = 20;
//$options['rowSubset'] = $subset;
$items = $crux->itemsOfTypeWithOptions ('document', $options );
// create property list for documents
foreach ($items as $document)
{
$comments = $document->comments;
$commentCount = count ( $comments );
$documentProperties = $document->propertyList();
// format comment count
if ( $commentCount == 1 )
$commentStatus = "1 comment";
elseif ( $commentCount == 0 )
$commentStatus = "no comments";
else
$commentStatus = sprintf ( "%s comments", $commentCount );
$documentProperties [ 'commentStatus' ] = $commentStatus;
// get last comment
if ( $commentCount > 0 )
{
$lastComment = $comments [ ($commentCount - 1) ];
$documentProperties [ 'lastComment' ] = $lastComment->propertyList();
$smarty->assign("shouldShowLastCommentDate", 0);
$a++;
} else {
$d++;
$smarty->assign("shouldShowLastCommentDate", 1);
}
$documents[] = $documentProperties;
}
// assign documents to template variable
$smarty->assign("documents", $documents);
$smarty->display('archives-tiger.tpl');
?>