PDA

View Full Version : Number of new posts in navbar?


94DROPTOPZ
02-01-2005, 09:51 AM
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:


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


Add this just above it:


//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:


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


Replace it with:


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

//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:


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


Replace it with:


<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
add to your phpinclude_start

//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:


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


Replace it with:


<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
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
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
add to your phpinclude_start

//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:


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


Replace it with:


<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.

/*
// 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