PDA

View Full Version : Query Database to see if new Posts have been made (Forumhome)


rin
06-29-2006, 08:14 AM
Hello,

I am working on a new Theme for my forums and I am using static HTML for my index!
That said, I can not use the regular lightbulb function of vBulletin.
To see what my page looks like, please go here:

http://www.kawaiination.com/uplo

You can see what I would like to have if you browse to the BLUE category, the Offtopic forum.
Something like "New Posts in Off Topic / Chit Chat (Post funny and ...)"

Can someone help me how I can handle this? I found the function dealing with the regular lightbulbs in /includes/functions_forumlist.php
But I don't know how I can do so I can use it in my HTML Page.

Thanks for any help.:)

Currently using vBulletin 3.0.X But planning to upgrade at a given time.

Paul M
06-29-2006, 04:44 PM
Perhaps take a look at how this mod does it and adapt as required.

https://vborg.vbsupport.ru/showthread.php?t=75320

rin
06-29-2006, 05:31 PM
Hello,

thanks for the hint. I read through the TXT and think you mean this one, right?
$postcount = $DB_site->query_first("SELECT COUNT(dateline) as pcount FROM ".TABLE_PREFIX."post WHERE dateline > ".$bbuserinfo['lastvisit']." ");

Basically, what I would do is:
Get the last post from the forum and check if it is newer or older than the last visit of the user?

If this is the way it works, would this in any kind be inferior to the way an unhacked vBulletin handles the lightbulbs?

I have tried to use your hack on a 3.5.4 forum. It does not work. It won't show anything in the templates.
I would assume, the if() is not working at all. Is there something I am not aware of?

unset($pcount, $rcount);
if ($bbuserinfo['userid'])
{
$pcount = "No New Posts since your last visit.";
$postcount = $DB_site->query_first("SELECT COUNT(dateline) as pcount FROM ".TABLE_PREFIX."post WHERE dateline > ".$bbuserinfo['lastvisit']." ");
if ($postcount['pcount'])
{
if ($postcount['pcount'] == 1)
{
$pcount = "<a href='search.php?do=getnew'><b>1 New Post</b></a> since your last visit.";
}
else
{
$pcount = "<a href='search.php?do=getnew'><b>".$postcount['pcount']." New Posts</b></a> since your last visit.";
}

}

sabret00the
06-30-2006, 07:25 AM
basically you're looking for
$data = $db->query_first("SELECT postid, MAX(dateline) FROM post WHERE dateline > " . $vbulletin->userinfo['lastvisit'] . "");

$newposts = (isset($data['postid'])) ? 'There are new posts since your last visit, why not check \'em out' : FALSE;

rin
06-30-2006, 08:01 AM
Thanks!
How can I check each forum? For example forum ids starting with 1 going till 20.
My target would be something like an array where I can ask the forum:
$newposts['$forumid']
Because I need to check if there are new posts in the forum manually for each forum.

sabret00the
06-30-2006, 09:36 AM
you'd change the query $data = $db->query_first("SELECT postid, MAX(dateline) FROM post WHERE dateline > " . $vbulletin->userinfo['lastvisit'] . " AND forumid = $forumid");

Please not, these are example queries, i'm not totally sure they'll work, though they should and there could be a cheaper way to do it, these are just off the top of my head.

rin
07-02-2006, 12:24 PM
Thanks a lot! I will try the last one tonight and give feedback as soon as possible. :)