vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Modification Requests/Questions (Unpaid) (https://vborg.vbsupport.ru/forumdisplay.php?f=112)
-   -   Number of new posts in navbar? (https://vborg.vbsupport.ru/showthread.php?t=75539)

94DROPTOPZ 02-01-2005 09:51 AM

Number of new posts in navbar?
 
I'm sure that this is pretty simple for some of you and I have messed with it a bit and can't seem to get it to work. What I'm looking to do is add the number of new posts next to the "New Posts" link in the nav bar, just so before they click the new posts they have an idea of how many new posts there are. I saw this on another site and I think that it's a good idea.

I have seen Garys "hack" but it's really not what I'm looking for right now...

Thanks in advance for your help

ericgtr 02-01-2005 02:15 PM

Here you go, this query is compliments of vBadvanced.

In your vbroot/index.php find:

PHP Code:

// ### ALL DONE! SPIT OUT THE HTML AND LET'S GET OUTA HERE... ### 

Add this just above it:

PHP Code:

//New Posts
        
$getnewposts $DB_site->query_first("SELECT COUNT(*) AS count FROM " TABLE_PREFIX "post WHERE dateline >= '$bbuserinfo[lastvisit]'");
        
$newposts number_format($getnewposts['count']);
//New Posts 

In your navbar template find:

PHP Code:

<td class="vbmenu_control"><a href="search.php?$session[sessionurl]do=getnew" accesskey="2">$vbphrase[new_posts_nav]</a></td

Replace it with:

PHP Code:

<td class="vbmenu_control"><a href="search.php?$session[sessionurl]do=getnew" accesskey="2">$vbphrase[new_posts_nav]</a> ($newposts new)</td

That's it! :)

sabret00the 02-01-2005 02:21 PM

you should've done this with the php_include template ;)

ericgtr 02-01-2005 02:28 PM

Quote:

Originally Posted by sabret00the
you should've done this with the php_include template ;)

Post it up, let's give him some options :)

sabret00the 02-01-2005 04:46 PM

add to your phpinclude_start
PHP Code:

//New Posts
        
$getnewposts =$DB_site->query_first("SELECT COUNT(*) AS count FROM " .TABLE_PREFIX "post WHERE dateline >= '$bbuserinfo[lastvisit]'");
        
$newposts number_format($getnewposts['count']);
//New Posts 

In your navbar template find:

PHP Code:

<td class="vbmenu_control"><ahref="search.php?$session[sessionurl]do=getnew"accesskey="2">$vbphrase[new_posts_nav]</a></td

Replace it with:

PHP Code:

<td class="vbmenu_control"><ahref="search.php?$session[sessionurl]do=getnew"accesskey="2">$vbphrase[new_posts_nav]</a> ($newpostsnew)</td

That's it! :)

ericgtr 02-01-2005 05:31 PM

Quote:

Originally Posted by sabret00the
add to your phpinclude_start
PHP Code:

//New Posts
        
$getnewposts =$DB_site->query_first("SELECT COUNT(*) AS count FROM " .TABLE_PREFIX "post WHERE dateline >= '$bbuserinfo[lastvisit]'");
        
$newposts number_format($getnewposts['count']);
//New Posts 

In your navbar template find:

PHP Code:

<td class="vbmenu_control"><ahref="search.php?$session[sessionurl]do=getnew"accesskey="2">$vbphrase[new_posts_nav]</a></td

Replace it with:

PHP Code:

<td class="vbmenu_control"><ahref="search.php?$session[sessionurl]do=getnew"accesskey="2">$vbphrase[new_posts_nav]</a> ($newpostsnew)</td

That's it! :)

Cool, so this will add the query anywhere on the site regardless if the navbar is on the page or not? I realize most pages have it anyway but I am wondering about overhead.

Seiken 02-01-2005 09:59 PM

Thats cool even though its only one edit. But its conveinent.

94DROPTOPZ 02-01-2005 10:05 PM

Thank you guys very much, I will try this...

sabret00the 02-02-2005 11:40 AM

Quote:

Originally Posted by ericgtr
Cool, so this will add the query anywhere on the site regardless if the navbar is on the page or not? I realize most pages have it anyway but I am wondering about overhead.

yup one query to everypage, not sure how worth it, it is, but it's not alot and won't every bring the server to it's needs or nothing of the sort.

SGT Rock 03-21-2005 02:18 PM

All I get is a set of parenthesis without a number: ()

ericgtr 03-21-2005 02:35 PM

Quote:

Originally Posted by SGT Rock
All I get is a set of parenthesis without a number: ()

Did you add the edit to your phpinclude_start? I haven't tried it there (where sabret00the suggests) but it looks like it should work with out a problem.

SGT Rock 03-21-2005 02:47 PM

yep, I followed sabertooth to the letter

dmbooth0310 08-03-2005 09:46 PM

I know this is old but how would I get this to work with vBadvanced? It doesn't show a zero on the portal, just ()

SlowFiveOh 11-20-2008 06:27 PM

Quote:

Originally Posted by sabret00the (Post 606027)
add to your phpinclude_start
PHP Code:

//New Posts
        
$getnewposts =$DB_site->query_first("SELECT COUNT(*) AS count FROM " .TABLE_PREFIX "post WHERE dateline >= '$bbuserinfo[lastvisit]'");
        
$newposts number_format($getnewposts['count']);
//New Posts 

In your navbar template find:

PHP Code:

<td class="vbmenu_control"><ahref="search.php?$session[sessionurl]do=getnew"accesskey="2">$vbphrase[new_posts_nav]</a></td

Replace it with:

PHP Code:

<td class="vbmenu_control"><ahref="search.php?$session[sessionurl]do=getnew"accesskey="2">$vbphrase[new_posts_nav]</a> ($newpostsnew)</td

That's it! :)

I know this thread is old. But will this work as described in 3.7? Also, when i add the code to my phpinclude_start template, do I delete what is there? This is what it has now.

PHP Code:

/*
// Example of how to include a seperate file:

ob_start();
include('yourheader.html');
$your_code = ob_get_contents();
ob_end_clean();

// Now place a reference to $your_code where you want the resulting HTML to be displayed.
// This will most likely be the header or footer template.
*/
$getnewpost=$DB_site->query_first("SELECT count(*) AS posts FROM ".TABLE_PREFIX."post WHERE dateline > '$bbuserinfo 


Lynne 11-20-2008 07:48 PM

I think now days you would put the code in a plugin - maybe at the global_start hook location.

artscripts 11-12-2011 12:54 PM

Help make it into 4.1.7


All times are GMT. The time now is 03:54 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.01235 seconds
  • Memory Usage 1,790KB
  • 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
  • (14)bbcode_php_printable
  • (5)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (16)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