View Full Version : [Release VB2] Total Thread Views
SystemLogic
Fri 20th Apr '01, 6:34pm
This hack was done by Kier, just wanted to post it in its own thread :)
What It Does
Counts all the views for each thread and adds them together. Basically a sum of the pageviews for all of your threads.
How To Implement This
Copy and paste this code into index.php in the regular forum directory.
// Total Thread Views
$boardviews = $DB_site->query_first("
SELECT SUM(views) AS threadviews FROM thread");
$totalviews = number_format($boardviews[threadviews]);
Then just print $totalviews anywhere you want.
Example: http://www.systemlogic.net/boards on the top left next to the number of posts/threads stats.
bokhalifa
Sat 21st Apr '01, 12:22am
good hack min :D
JJR512
Sat 21st Apr '01, 1:07am
This is a cool little hack, I've just implemented it with no problems other than my own stupidity (I forgot to upload the new index.php -- d'Oh!).
Anyway, after I installed it and looked at it (I put the output on a new line under the thread and post counts), it occurred to me that if you've imported from UBB (as I have), this isn't really a true count. UBB doesn't keep track of thread views, so however many you had while using UBB don't count. Your actual number may be a little higher or much higher; there's no real way to know.
This is not a criticism; I don't mean to rain on this parade. I'm just pointing it out, that's all.
eva2000
Sat 21st Apr '01, 1:35am
nice :)
SystemLogic
Sat 21st Apr '01, 1:47pm
Anyway, after I installed it and looked at it (I put the output on a new line under the thread and post counts), it occurred to me that if you've imported from UBB (as I have), this isn't really a true count. UBB doesn't keep track of thread views, so however many you had while using UBB don't count. Your actual number may be a little higher or much higher; there's no real way to know.
Yup, you're right, but I guess it's a good thing if you're starting over or just starting up using VBulletin. If you're importing into VB from anything else like UBB, it won't convert the thread views.....Just thought it be cool to have for those that wanted it :)
The_Sisko
Sat 21st Apr '01, 6:26pm
Good idea! Thx for repost it as a own thread.:)
n3n
Fri 27th Apr '01, 1:58am
great little hack!!
I have added this feature on my forum ^_^
thanks
TimberLand
Mon 7th May '01, 7:29pm
As far as the ubb missing views, could you add a little saying as of May 7, 2001 or something like that. If so how would I do that?
Dan
Sarge
Tue 8th May '01, 5:49pm
where do I insert this at?
what line number?
And what about adding "Thread views since""
Like posted above
Great idea.
TimberLand
Wed 9th May '01, 12:21am
That was just an idea I had. I would like to know as well. Any hackers interested.
Sarge
Wed 9th May '01, 12:26am
easy dude
Just insert
$totalviews since 1-5-01 into where you want it on your forum home template
:)
JJR512
Wed 9th May '01, 12:27am
Well, it's very simple. Where ever you stick the $totalviews, just put the text by that. For example, if you put it in your forumhome template, so it's below your total threads and total posts, as I did, like this:
<b>$totalviews</b> total thread views
You could just change it to this:
<b>$totalviews</b> total thread views since May 7, 2001
(Or use whatever date it was when you converted from UBB to vB.)
TimberLand
Wed 9th May '01, 1:31am
Where do you paste the code at, in the index.php? Anywhere special.
Can someone give an example of placement.
Thanks
Dan
Sarge
Wed 9th May '01, 1:35am
in the forum home template
Put it under launch buddy list or wherever
JJR512
Wed 9th May '01, 1:42am
Originally posted by JJR512
Well, it's very simple. Where ever you stick the $totalviews, just put the text by that. For example, if you put it in your forumhome template, so it's below your total threads and total posts, as I did, like this:
<b>$totalviews</b> total thread views
You could just change it to this:
<b>$totalviews</b> total thread views since May 7, 2001
(Or use whatever date it was when you converted from UBB to vB.)
TimberLand
Wed 9th May '01, 2:01am
Thanks very much,
What about the index.php file I need to edit. Where should I put the code it's says in the above post. It say cut and paste this code into the index.php file.
Sarge
Wed 9th May '01, 2:03am
just find a place... like under total posts in index.php
TimberLand
Wed 9th May '01, 8:46am
I can't find total posts in the index.php file. Can someone cut out a small part of this file were they have this code placed in the index.php file?
// Total Thread Views
$boardviews = $DB_site->query_first("
SELECT SUM(views) AS threadviews FROM thread");
$totalviews = number_format($boardviews[threadviews]);
JJR512
Wed 9th May '01, 1:40pm
In index.php, look for this:
// get newest member
Place the code for this hack above this line.
This is how mine looks:
// get total posts
$countposts=$DB_site->query_first('SELECT COUNT(*) AS posts FROM post');
$totalposts=$countposts['posts'];
if ($totalposts=='') {
$totalposts=0;
}
$countthreads=$DB_site->query_first('SELECT COUNT(*) AS threads FROM thread');
$totalthreads=$countthreads['threads'];
if ($totalthreads=='') {
$totalthreads=0;
}
// Total Thread Views
$boardviews = $DB_site->query_first("
SELECT SUM(views) AS threadviews FROM thread");
$totalviews = number_format($boardviews[threadviews]);
// get newest member
$getnewestusers=$DB_site->query_first("SELECT userid,username FROM user WHERE userid=$numbersmembers[max]");
$newusername=$getnewestusers['username'];
$newuserid=$getnewestusers['userid'];
TimberLand
Thu 10th May '01, 1:09am
Worked like a charm. I was getting messed up because I didn't realize at first there are two index files.
Alwaysmefirst
Sun 27th May '01, 5:50am
Very cool hack :)
Thanks for posting it.
Olly
max
Mon 28th May '01, 1:34pm
Thanks for the hack, very nice.
Is there any way to include this hack onto a Non-VB page?
I've added the correct code into my /forums/index.php..
and then I made a new file named totalthreadviews.inc.php with this code:
<?php
$font = "Verdana";
$fontsize = "8pt";
require("/home/max/public_html/forums/index.php");
$boardviews = $DB_site->query_first("
SELECT SUM(views) AS threadviews FROM thread");
$totalviews = number_format($boardviews[threadviews]);
echo "<font-family: $font; font-size: $fontsize\"><b>$totalviews</b> total thread views</font>";
?>
Then I opened up my non-vb page and tried to include that file.. but it didn't work at all..
Any ideas on this one?
Martz
Tue 29th May '01, 9:54am
Very nice and simple hack, appreciated :)
Zorg
Sat 9th Jun '01, 9:27am
That's a great hack, thanks alot :D
Any change of putting this into the "stats" in the VB control panel to give more of a per day/week/month effect listing?
Streicher
Mon 11th Jun '01, 4:22pm
If you want the views displayed without a "," then use this code instead:
$boardviews=$DB_site->query_first("SELECT SUM(views) AS threadviews FROM thread");
$totalviews=$boardviews['threadviews'];
express
Wed 13th Jun '01, 9:33am
Thanks for the hack. Works Great
Joey;)
Thomas P
Fri 15th Jun '01, 7:51am
Originally posted by Streicher
[B]If you want the views displayed without a "," then use this code instead (...)
Thanks - that was what I was looking for! :D
Grüße nach Reinbek,
-Tom
king98
Sat 16th Jun '01, 6:29am
i tried to post that code in the index.php file but it did not work .... can some body add this hack to that file and put it for downloading plz.:(
express
Thu 12th Jul '01, 10:34am
Hack works great.
How would someone also add under a members profile the total amount of page views that member has?
Lukman
Fri 13th Jul '01, 1:59pm
I think im the only one who cant get this hack to work :(
I did two things as instructed - add that piece of code in my /forums/index.php file exactly the same way JJR512 did it
and I added <b>$totalviews</b> total thread views - in the forum home template
When I refreshed - all i saw was total thread view with no number next to it :(
Whats wrong?
Thanks in advance - im using v2.0.1 btw
express
Fri 13th Jul '01, 2:08pm
Here is how I have mind setup in the forumhome template.
Registered Members: <b>$numbermembers</b><br>
Total Threads: <b>$totalthreads</b> | Total Posts: <b>$totalposts</b> | Total Views: <b>$totalviews</b><br>
express
Fri 13th Jul '01, 2:12pm
This is what my index.php looks like.
$totalthreads=$countthreads['threads'];
if ($totalthreads=='') {
$totalthreads=0;
}
// Total Thread Views
$boardviews = $DB_site->query_first("
SELECT SUM(views) AS threadviews FROM thread");
$totalviews = number_format($boardviews[threadviews]);
Lukman
Fri 13th Jul '01, 2:27pm
Webhost
I thought u were just suppose to add
// Total Thread Views
$boardviews = $DB_site->query_first("
SELECT SUM(views) AS threadviews FROM thread");
$totalviews = number_format($boardviews[threadviews]);
How come you got some extra code above this?
btw - pardon my lack on php knowledge - but are there permissions set for php files?
express
Fri 13th Jul '01, 2:31pm
yes code above above ties in with something else.
Email me your index.php and forumhome template for me to look at to joeymoses1@home.com
Lukman
Fri 13th Jul '01, 2:50pm
Here you go Webhost or anyone else who is willing 2 help me out :) - I copied and pasted the forum home template source in a txt file
Thanks :)
This is how i edited the index.php file -
I went to my ftp proggy (Cute FTP) first I made a backup of the index file by downloading it on my harddisk - then I right clicked and edited the index file from my uploaded version - it opened into notepad - then added the code - and uploaded the amended version..
I take it php files do not have chmod permissions, do they?
express
Fri 13th Jul '01, 4:42pm
Try inserting the bold item below
// Total Thread Views
$boardviews = $DB_site->query_first("
SELECT SUM(views) AS threadviews FROM thread");
$totalviews = number_format($boardviews[threadviews]);
}<--- I think you need that
// get newest member
$getnewestusers=$DB_site->query_first("SELECT userid,username FROM user WHERE userid=$numbersmembers[max]");
$newusername=$getnewestusers['username'];
$newuserid=$getnewestusers['userid'];
mjames
Fri 13th Jul '01, 10:14pm
Love this simple hack. Got it installed on my boards. Good job!
Lukman
Fri 13th Jul '01, 11:52pm
webhost mate - tried that = still no joy :(
I guess this hack doesnt wanna work on my board! ( sob sob)
Anybody got any other ideas?
express
Sat 14th Jul '01, 12:24am
try uploading this index.php file, first backup your file on your hardrive then delete the index.php file on your server and upload this one.
[Zip Removed -- don't post full source code!]
express
Sat 14th Jul '01, 12:26am
lukman give a url to your board
ForzaGrifo
Mon 16th Jul '01, 1:32am
Lukman, try removing the spaces around the = signs. I had the same problem and now it's working perfect. That should do the trick.
Anyone knows why the lines won't get parsed if there's space around the equal sign?
Lukman
Tue 17th Jul '01, 12:35pm
Ive tried everything - no luckwhatsoever :(
I removed the spaces between the = sign - even uploaded webhosts index.php file but to no avail!
Ive gived up now - It would have been nice to see an extra stat on the main page but oh well - it dont matter!
Thanks Webhost for all yer help and same goes for ForzaGrifo
express
Tue 17th Jul '01, 12:51pm
Lukman
With the new index.php file and template loaded with the script in it open your forum to the first page. Once there right click and view source. Save this file and email it to me Joeymoses1@home.com
TripleH
Fri 20th Jul '01, 1:56am
How can I put it so under the avatar it shows how many personal views tehre are??
and same with threads starteD? i have seen it done but not sure how..
thanks'
HHH
express
Fri 20th Jul '01, 5:24am
http://www.vbulletin.com/forum/showthread.php?threadid=17116
Kengan
Fri 27th Jul '01, 9:04pm
Good Hack !! Like it ! ;)
Thomas P
Thu 2nd Aug '01, 5:12pm
Works great!
TripleH
Sat 4th Aug '01, 2:11am
Ok. I got the personal views.. But now I don't know how to get the threads started to show up... I can get it to show up in the members profile, but i can't get it to show up in the postbit template where it shows how many personal views, posts, and other crap is..
anyone know how?
HHH
Kengan
Thu 9th Aug '01, 6:31pm
Cool hack ! I like it ! thanks ! Rocks !
express
Thu 9th Aug '01, 7:16pm
are you using vb 2.0.3
dilirum
Sun 19th Aug '01, 8:42am
Works great for me... thanks.
LuBi
Sun 26th Aug '01, 11:04am
Does this work in 2.0.3?
mjames
Sun 26th Aug '01, 10:50pm
Originally posted by LuBi
Does this work in 2.0.3?
You bet - here is a working example: http://sportscentralboards.com
eva2000
Sun 26th Aug '01, 10:51pm
Originally posted by LuBi
Does this work in 2.0.3? yup i have total threadviews at the top of my forum and total pageviews at the bottom http://vbulletin.com/forum/showthread.php?s=&threadid=26527 :D
atrl
Fri 12th Oct '01, 9:49pm
Is there any way to make it so it can display daily, Record, and Total?
vBulletin® v3.8.0 Alpha 1, Copyright ©2000-2008, Jelsoft Enterprises Ltd.