Miscellaneous

Joomla에서 Compojoom Comment 수 보여주기

빅토르최·2014년 2월 25일·조회 2,349

com_content에 comment 수를 보여준다고 하면,

먼저 함수를 만듭니다.

function cu_GetCommentCount($id, $component = 'com_content') {
        //this function gets a count of comments for the given content item

        $result = false;
        $db = JFactory::getDBO();
        $query = $db->getQuery(true);
        $query->select('COUNT(id)');
        $query->from('#__comment');
        $query->where('component = '.$db->quote($component));
        $query->where('contentid = '.$db->quote(intval($id)));
        $db->setQuery($query);
        $count = $db->loadResult();

        if ($count !== false) { $result = intval($count); }
        return $result;
}

Comment 수를 보여주고 싶은 곳에 다음 코드를 삽입합니다.

?php echo cu_GetCommentCount($article->id, 'com_content'); ?>

참조 사이트:

https://compojoom.com/forum/50-wishlist/17347-add-comments-count-next-to-article-title

댓글 0

로그인 후 댓글을 남길 수 있습니다.

아직 댓글이 없습니다.