vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Query Database to see if new Posts have been made (Forumhome) (https://vborg.vbsupport.ru/showthread.php?t=119866)

rin 06-29-2006 07:14 AM

Query Database to see if new Posts have been made (Forumhome)
 
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 03: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 04:31 PM

Hello,

thanks for the hint. I read through the TXT and think you mean this one, right?
Code:

$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?

Code:

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 06:25 AM

basically you're looking for
PHP Code:

$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 07: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:
Code:

$newposts['$forumid']
Because I need to check if there are new posts in the forum manually for each forum.

sabret00the 06-30-2006 08:36 AM

you'd change the query
PHP Code:

$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 11:24 AM

Thanks a lot! I will try the last one tonight and give feedback as soon as possible. :)


All times are GMT. The time now is 11:26 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.02159 seconds
  • Memory Usage 1,733KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_code_printable
  • (2)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete