Moderators: jmacgreg, michael, jheckman, barbarah, btbell, bdgregg, asmecher
/**
* Check how many comments each article has.
* @param $articleId int The ID of the article to check
* @return boolean
*/
function attributedCommentsExistForArticle($articleId) {
$result =& $this->retrieve('SELECT count(*) FROM comments WHERE article_id = ?', (int) $articleId);
$returner = $result->fields[0]?true:false;
$result->Close();
return $returner;
}
$commentDao =& DAORegistry::getDAO('CommentDAO');
$commentDao->attributedCommentsExistForArticle($articleID);
$CommentDAO =& DAORegistry::getDAO('CommentDAO');
$templateMgr->assign('CommentDAO', $CommentDAO);
function attributedCommentsExistForArticle($articleId) {
$result =& $this->retrieve('SELECT count(*) FROM comments WHERE article_id = ?', (int) $articleId);
$returner = $result->fields[0];
$result->Close();
return $returner;
}
{$CommentDAO->attributedCommentsExistForArticle($articleID)}
{if $CommentDAO->attributedCommentsExistForArticle($article->getArticleId())}
{if $CommentDAO->attributedCommentsExistForArticle($article->getArticleId()) == 1}
<a href="{$baseUrl}/comment/view/{$article->getArticleId()}/0" class="file">Comment ({$CommentDAO->attributedCommentsExistForArticle($article->getArticleId())})</a>
{else}
<a href="{$baseUrl}/comment/view/{$article->getArticleId()}/0" class="file">Comments ({$CommentDAO->attributedCommentsExistForArticle($article->getArticleId())})</a>
{/if}
{else}
<a href="{$baseUrl}/comment/view/{$article->getArticleId()}/0" class="file">Add a comment</a>
{/if}
Users browsing this forum: No registered users and 2 guests