Welcome, Guest. Please login or register.
August 20, 2008, 05:28:36 PM

Login with username, password and session length
Search:     Advanced search
Website Baker 2.7.0 (stable) released!
For more information look here.
The announcement board can be found here.
60556 Posts in 9791 Topics by 5824 Members
Latest Member: blubb
* Home Help Search Login Register
+  Website Baker Community Forum
|-+  English
| |-+  Modules
| | |-+  News Module - Counting of Comments
Pages: [1] Go Down Print
Author Topic: News Module - Counting of Comments  (Read 1924 times)
rodneyw
Pending Apprentice Baker
**
Offline Offline

Posts: 3


Email
« on: May 05, 2007, 12:22:37 AM »

the only thing I can find on adding the ability to display the number of comments in the news module is not working. Post look to be from 2005 so I'm sure some of the base code has changed.

the count seems to be working (i can display it in the footer of the detail page of the news article) but it will not assign to a label so that I can call it on the main news page.

Can someone look at this code and see if I messed something up

Code:
// Query for comments
$query_comments = $database->query("SELECT title,comment,commented_when,commented_by FROM ".TABLE_PREFIX."mod_news_comments WHERE post_id = '".POST_ID."' ORDER BY commented_when ASC");
$comments_count=$query_comments->numRows();
if($query_comments->numRows() > 0) {
while($comment = $query_comments->fetchRow()) {
// Display Comments without slashes, but with new-line characters
$comment['comment'] = nl2br(($comment['comment']));
$comment['title'] = ($comment['title']);
// Print comments loop
$commented_date = gmdate(DATE_FORMAT, $comment['commented_when']+TIMEZONE);
$commented_time = gmdate(TIME_FORMAT, $comment['commented_when']+TIMEZONE);
$uid = $comment['commented_by'];
$vars = array('[TITLE]','[COMMENT]','[DATE]','[TIME]','[USER_ID]','[USERNAME]','[DISPLAY_NAME]', '[EMAIL]','[COMMENTS_COUNT]');
if(isset($users[$uid]['username']) AND $users[$uid]['username'] != '') {
$values = array(($comment['title']), ($comment['comment']), $commented_date, $commented_time, $uid, ($users[$uid]['username']), ($users[$uid]['display_name']), ($users[$uid]['email']), $comments_count);
} else {
$values = array(($comment['title']), ($comment['comment']), $commented_date, $commented_time, '0', strtolower($TEXT['UNKNOWN']), $TEXT['UNKNOWN'], '', $comments_count);
}
echo str_replace($vars, $values, $setting_comments_loop);
}

in the NEWS settings I'm trying to call the number with [COMMENTS_COUNT]



seems like I've just overlooked something but I can't see it right now

thanks
Logged
rodneyw
Pending Apprentice Baker
**
Offline Offline

Posts: 3


Email
« Reply #1 on: May 05, 2007, 01:28:16 AM »

after working with this i think i have the code in the wrong place. Are there any current hacks for the news module for the new version of Baker to display the number of comments?
Logged
macsmet
Apprentice Baker
***
Offline Offline

Posts: 92


« Reply #2 on: May 05, 2007, 06:02:52 PM »

Hi there,

I added my view.php file in which I added the comment_count.

Have fun with it!

MacSmet
Logged
AzAkers
Pending Apprentice Baker
**
Offline Offline

Posts: 42


WWW Email
« Reply #3 on: August 03, 2007, 07:39:29 AM »

Thanks for sharing - helped me when I modded my blog to show counts below the short description

"helped" is the wrong word... made it possible is more accurate Wink   I'm no programmer so sharing these little snippets really help - thanks!
Logged

Contributor?  THANKS!!

WB Sites:
AZ Ladies Ministries
Logo Design in progress
jar
Pending Apprentice Baker
**
Offline Offline

Posts: 41


« Reply #4 on: August 20, 2007, 12:00:32 AM »

Hi there,

I added my view.php file in which I added the comment_count.

Have fun with it!

MacSmet
Please help me !! i added the code in wiew.php ..
i call the function with [COMMENTS_COUNT]
Does`n work
i  have a error like this :
Parse error: syntax error, unexpected $end in /home/mardofas/public_html/baker/modules/news/view.php on line 321

tell me what to do .. please !
Logged
Rahya
Apprentice Baker
***
Offline Offline

Posts: 60


40456115 anya@directbox.com RealAnya Rahya
WWW
« Reply #5 on: July 02, 2008, 05:03:35 PM »

I'm searching for a solution, that shows me, how much comments are for the only news-posts on the news-start-page... looks like:


TITLE                                   DATE
SHORT SHORT
>> READ MORE
COMMENTS: x

just like the news-page that shows in the backend, how much comments are in the post...
Logged

Meine Rüstung ist die Ironie, mein Schild der Zynismus und mein Schwert der Sarkasmus...
Pages: [1] Go Up Print 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.5 | SMF © 2006-2008, Simple Machines LLC Valid XHTML 1.0! Valid CSS!