PDA

View Full Version : Number of posts in thread since last visited


Vociferous
10-05-2001, 06:57 PM
I have been browsing the various hacks available for VB 2.x and I do not see one which would do the following:

In a seperate table (preferably next to how many posts are in a thread) would be a count for how many new posts are in the thread since it was last visited.

This would require a thread to be marked as read after visiting it and not only after clicking the link that says "Mark all Forums Read".

Is there a hack out there that already does this that I missed?

If there isn't-- could we do it?

Thanks! :)

Vociferous
10-06-2001, 04:57 PM
~bump~

updated my profile with my customer id #
maybe I'll get a response now. :)

tubedogg
10-06-2001, 07:11 PM
Actually it'd be a lot easier and a lot more feasible than the way you suggested. :) Just count the number of posts in each thread that are new since the person's last visit in forumdisplay.php :)

Vociferous
10-06-2001, 09:05 PM
I hadn't thought about that and it seems like that would do the trick for a slower forum-- I'd like to see it. ;)

The reason I descibed it the way I did is I'm looking at moving an extremely active (5,000+ new posts/replys every month) WebX community over to VB. They can see with each refresh of the thread-listing's page how many new posts are on each thread since they last openned them (even if it's only been 30 seconds).
I'd like to not alienate anyone from the boards simply because they don't like the change.
It'd be easier if people accepted change as easily as myself-- but most people don't and there-in lies my problem.

What I'm looking at doing is creating a carbon copy of the current WebX layout (at least on the surface) with VB in order to allow the members to make a smooth transfer over to the new boards with a minimum amount of problems.

Basically, if it looks the same, works the same, they'll think it is the same-- even though it isn't the same.

Am I making sense? :)

And if anyone wonders why I'm moving to VB over WebX-- it's because WebX is overpriced, underpowered, and is more of a bandwidth hog than UBB. :p

tubedogg
10-06-2001, 11:20 PM
Either method would be OK for a smaller forum. However the method you suggest would be an absolute server-killer for a decent sized forum because of the amount of data involved in marking each thread read, as has been discussed here elsewhere before.

Anyway this sounded interesting so I whipped up something for my forums. Code changes are below - it's actually quite simple.

In forumdisplay.php find$threadids='thread.threadid IN (0'.$stickyids;
Replace it with$threadids='threadid IN (0'.$stickyids;
Find // check to see if there are any threads to display. If there are, do so, otherwise, show message
Right below it add$posts = $DB_site->query("SELECT COUNT(*) AS posts,threadid FROM post WHERE $threadids AND dateline>$bbuserinfo[lastvisit] GROUP BY threadid");
while ($post = $DB_site->fetch_array($posts)) {
$newpost[$post[threadid]] = $post[posts];
}
Find if (($bbuserinfo[maxposts] != -1) and ($bbuserinfo[maxposts] != 0))
Right above it add if ($newpost[$thread[threadid]]) {
$newposts = $newpost[$thread[threadid]];
eval("\$numnew = \"".gettemplate('forumdisplaybit_newposts')."\";");
} else {
$newposts = " ";
eval("\$numnew = \"".gettemplate('forumdisplaybit_newposts')."\";");
}
And then you need to add a template named forumdisplaybit_newposts with the following contents:($newposts new post(s))

And then edit the forumdisplay_threadslist template...
Find <td bgcolor="{tableheadbgcolor}" nowrap><smallfont><a href="$sorturl&sortorder=desc&sortfield=replycount"><font color="{tableheadtextcolor}"><b>Replies</b></font></a> $sortarrow[replycount]</smallfont></td>
Right below it add <td bgcolor="{tableheadbgcolor}" nowrap><smallfont><font color="{tableheadtextcolor}"><b>New Posts</b></font></smallfont></td>
Then find <td bgcolor="{tableheadbgcolor}" width="100%" colspan="8" align="center"><smallfont color="{tableheadtextcolor}">
and change the "8" to "9".
Then in the forumdisplaybit template find <td bgcolor="$fbackcolor"><normalfont>$thread[views]</normalfont></td>
and right *above* it add <td bgcolor="$fbackcolor"><normalfont>$numnew</normalfont></td>
And that's it.

Vociferous
10-06-2001, 11:46 PM
Indeed.

The servers running WebX now are extremely over-taxed and we have to auto-prune old threads after only a few days of their becoming idle. I was hoping VB could prove more adept at helping the servers handle such stresses. :o

I appreciate your work so far though! :)
I'm adding your code modifications as we speak so I can test it out. :)

Any other ideas that might accomplish the same thing? Or should it even be considered? :\

tubedogg
10-06-2001, 11:50 PM
Originally posted by Vociferous
The servers running WebX now are extremely over-taxed and we have to auto-prune old threads after only a few days of their becoming idle. I was hoping VB could prove more adept at helping the servers handle such stresses. :oOh, we definitely can. However that kind of thing would kill any message board system with enough stress. I don't know the method WebX uses for it, nor do I have any idea what WebX even uses as far as software, but for vB's MySQL database it would be far too much data to handle.

Vociferous
10-07-2001, 12:01 AM
Well currently the entire system has roughly 108,000 posts on it.

I'm looking at a single forum at the moment which is a mere 10-20% of that with VB if possible just to do stress tests.

soceris
10-08-2001, 11:27 AM
i can't finmd teh final bit in my forumdisplay template

any ideas why????

amykhar
10-08-2001, 11:33 AM
soceris,
I don't advise trying this hack. It was giving me errors both times I tried to install it. I haven't had time to try to debug it.

Amy

Vociferous
10-08-2001, 11:20 PM
Hmm.... I'm running 2.0.3 on the test board.

well, I did some testing and I got this to work :) I made some assumptions though.

I assumed (as soceris pointed out as a problem) that the following supposedly in the forumdisplay template
<td bgcolor="$fbackcolor"><normalfont>$numnew</normalfont></td>

was actually supposed to go into the forumdisplaybit template

however, if it goes into forumdisplaybit template then it should be as follows:

Step 1) In forumdisplaybit find:
<td bgcolor="#DFDFDF"><normalfont>$thread[views]</normalfont></td>

Step 2) Replace that with:
<td bgcolor="#F1F1F1"><normalfont>$thread[views]</normalfont></td>

Step 3) Insert the following above it:
<td bgcolor="#DFDFDF"><normalfont>$numnew</normalfont></td>

No errors for me though! Not sure why you are getting them Amy. :confused:

tubedogg, would you mind telling me/us whether I was correct in assuming the final step is supposed to be in the forumdisplaybit template?

Dave

Vociferous
10-08-2001, 11:27 PM
okay, this board keeps turning my variables into hex color code! :rolleyes:

Trying this again.

edit:

that didn't work...

Vociferous
10-08-2001, 11:32 PM
fine, the step by step instructions (with the correct code) are in the attached txt file and I think if nothing else. tubedogg changed the variables just to get it to post here on these forums. lol :D

edit:

Even text files are against me! :mad:

okay, last shot at this.


Step 1) In forumdisplaybit find:
<td bgcolor="(secondaltcolor)"><normalfont>$thread[views]</normalfont></td>


Step 2) Replace that with:
<td bgcolor="(firstaltcolor)"><normalfont>$thread[views]</normalfont></td>


Step 3) Insert the following above it:
<td bgcolor="(secondaltcolor)"><normalfont>$numnew</normalfont></td>

just change the ( and ) to { and }

this better work-- I'm stubborn, but not that stubborn.

Vociferous
10-09-2001, 12:15 AM
Okay, I made some changes to the code and here are the modified instructions:

In forumdisplay.php find
$threadids='thread.threadid IN (0'.$stickyids;
Replace it with
$threadids='threadid IN (0'.$stickyids;
Find
// check to see if there are any threads to display. If there are, do so, otherwise, show message
Right below it add
$posts = $DB_site->query("SELECT COUNT(*) AS posts,threadid FROM post WHERE $threadids AND dateline>$bbuserinfo[lastvisit] GROUP BY threadid");
while ($post = $DB_site->fetch_array($posts)) {
$newpost[$post[threadid]] = $post[posts];
}
Find
if (($bbuserinfo[maxposts] != -1) and ($bbuserinfo[maxposts] != 0))
Right above it add
if ($newpost[$thread[threadid]]) {
$newposts = $newpost[$thread[threadid]];
eval("\$numnew = \"".gettemplate('forumdisplaybit_newposts')."\";");
} else {
$newposts = "0";
eval("\$numnew = \"".gettemplate('forumdisplaybit_newposts')."\";");
}

And then you need to add a template named forumdisplaybit_newposts with the following contents:
$newposts

And then edit the forumdisplay_threadslist template
<td bgcolor="{tableheadbgcolor}" nowrap><smallfont><a href="$sorturl&sortorder=desc&sortfield=replycount"><font color="{tableheadtextcolor}"><b>Replies</b></font></a> $sortarrow[replycount]</smallfont></td>
Right below it add
<td bgcolor="{tableheadbgcolor}" nowrap><smallfont><font color="{tableheadtextcolor}"><b>New Posts</b></font></smallfont></td>
Then find
<td bgcolor="{tableheadbgcolor}" width="100%" colspan="8" align="center"><smallfont color="{tableheadtextcolor}">
Important! Change the "8" to "9".


Then in the forumdisplaybit template do the following:

Step 1) In forumdisplaybit find:
<td bgcolor="(secondaltcolor)"><normalfont>$thread[views]</normalfont></td>


Step 2) Replace that with:
<td bgcolor="(firstaltcolor)"><normalfont>$thread[views]</normalfont></td>


Step 3) Insert the following above it:
<td bgcolor="(secondaltcolor)"><normalfont>$numnew</normalfont></td>

just change the ( and ) to { and }


And that's it! :D

*************************

After going through and changing the instructions I saw that it was indeed forumdisplaybit. :rolleyes:

anyway, tubedogg-- you rock! :) thanks man!

Dave

Vociferous
10-09-2001, 12:18 AM
doh! Hex code again! Well, you guys understand right?

one last thing tubedogg...

how do you get it to not change the code to hex? ;)

tubedogg
10-09-2001, 12:33 AM
:D My secret ;) LOL

All I did was break it up with tags (kinda hard to explain, just look at the example below):
{secondaltcolor} <-- normally this would change, but when I add the following:
{secondaltcolor}
And then it appears correctly. Note I added some stuff for it to appear correctly for you, but the point is to use what I have actually put there and not what I used to make it. Confused yet? LOL :)

In the next version (2.0.4) you will be able to make these not change into hex by selecting the "disable smilies in this post" option.

Anyway you were right about the forumdisplay -> forumdisplaybit thing and I edited my post to reflect that.

Vociferous
10-09-2001, 12:58 AM
Ohhhhh :D

I'll remeber that for next time! Thanks :)