News:

Wondering if this will always be free?  See why free is better.

Main Menu

Number of unread posts

Started by SuperSkunk, December 26, 2009, 07:18:23 AM

Previous topic - Next topic

SuperSkunk

Hi everyone,

I want to display in BoardIndex.template.php, the number of unreaded post for a board.
I didn't find any variables like I want in $context['categories']['boards'].

Is there something already done or I have to create the variable ?

I want to display something like that :

QuoteMy board's name (13)

13 is the number of unreaded posts.

Thanks in advance !

Have a good day !

Arantor

#1
I don't believe there is such a variable; it's never stored anywhere, though I suppose it could be calculated - the only concern I'd have is the performance of doing it; you'd have to consider every single topic in that board to be able to figure out if it's been read or not.

EDIT: Actually it is calculated, my mistake. If you hover over the [new] button it actually tells you (in some themes, not all)

SuperSkunk

Are you sure ?

Because I found that in Core Theme:
$child['link'] = '<a href="' . $child['href'] . '" title="' . ($child['new'] ? $txt['new_posts'] : $txt['old_posts']) . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')">' . $child['name'] . '</a>';

But I think it's the number of posts and topics not the number of unreaded posts.
Do you have a link of a theme with that feature ?

Arantor

Hover over the button. What text does it tell you, exactly? I just checked this in Curve which has that exact same line.

On a child board where I had one unread post, it said to me: "New Posts (Topics: 1, Posts: 1)"

SuperSkunk

Well $txt['new_posts'], I think it's something like "New posts" and $txt['old_post'] it's "No new messages".

But I tried in this forum.
And after read a child, it's "No New posts (Topics:18,Messages:145)".

So it's really the number of posts...

Arantor

Which board was that? I don't think I can name any public board that has only 18 topics here.

SuperSkunk

http://www.simplemachines.org/community/index.php?board=186.0
;D

I'm looking for a function to do that, but I think it'll be to huge...
It's a bit weird that it's doesn't have that... I understand it's heavy but it's fun.

I don't have a lot of posts for considering the perfomance in a real environment.

Arantor

Hmm, yeah, you're right. Seems I was right the first time, that it doesn't count it separately.

Since there isn't actually any count of it in the core, the only option really is to request a mod, since it's not just a few lines of code to add. Board for that is Mod Requests, with the rules for it being READ ME: How To Request A Modification (Mod).

SuperSkunk

I'll post in SMF Coding Discussion when I have something...

I know a forum in Ajax that does that : www.subfactory.fr [nofollow] and it's does seams to be heavy.
I'll try to ask him.

The thing is that I didn't understand the log system.
smfrc2_log_topics
smfrc2_boards
smfrc2_log_mark_read
But not
smfrc2_log_messages
So...
Well I'll try to figure that out.

Arantor

The first tracks the latest id in a thread you've read, the second the boards you've read, the third the boards you've marked as read.

If you're willing to do it yourself, Coding Discussion is the place to go, but if you want someone to write it for you completely, Mod Requests is the place.

SuperSkunk

Ok, I see.
So I can do it without add a new table.

I'm a developper, so I can do something on my own, but it's just for doing it properly in the SMF system.
Thanks for your help.

Have a nice weekend !

Advertisement: