PDA

View Full Version : [Release VB2] Total Thread Views


SystemLogic
04-19-2001, 10:00 PM
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
04-21-2001, 03:22 AM
good hack min :D

JJR512
04-21-2001, 04:07 AM
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
04-21-2001, 04:35 AM
nice :)

SystemLogic
04-21-2001, 04:47 PM
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
04-21-2001, 09:26 PM
Good idea! Thx for repost it as a own thread.:)

n3n
04-27-2001, 04:58 AM
great little hack!!
I have added this feature on my forum ^_^
thanks

TimberLand
05-07-2001, 10:29 PM
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
05-08-2001, 08:49 PM
where do I insert this at?

what line number?

And what about adding "Thread views since""
Like posted above

Great idea.

TimberLand
05-09-2001, 03:21 AM
That was just an idea I had. I would like to know as well. Any hackers interested.

Sarge
05-09-2001, 03:26 AM
easy dude

Just insert

$totalviews since 1-5-01 into where you want it on your forum home template
:)

JJR512
05-09-2001, 03:27 AM
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
05-09-2001, 04:31 AM
Where do you paste the code at, in the index.php? Anywhere special.

Can someone give an example of placement.

Thanks
Dan

Sarge
05-09-2001, 04:35 AM
in the forum home template

Put it under launch buddy list or wherever

JJR512
05-09-2001, 04:42 AM
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
05-09-2001, 05:01 AM
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
05-09-2001, 05:03 AM
just find a place... like under total posts in index.php

TimberLand
05-09-2001, 11:46 AM
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
05-09-2001, 04:40 PM
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
05-10-2001, 04:09 AM
Worked like a charm. I was getting messed up because I didn't realize at first there are two index files.

Alwaysmefirst
05-27-2001, 08:50 AM
Very cool hack :)
Thanks for posting it.

Olly

max
05-28-2001, 04:34 PM
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
05-29-2001, 12:54 PM
Very nice and simple hack, appreciated :)

Zorg
06-09-2001, 12:27 PM
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
06-11-2001, 07:22 PM
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'];

webhost
06-13-2001, 12:33 PM
Thanks for the hack. Works Great

Joey;)

ThomasP
06-15-2001, 10:51 AM
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
06-16-2001, 09:29 AM
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.:(

webhost
07-12-2001, 01:34 PM
Hack works great.
How would someone also add under a members profile the total amount of page views that member has?

Lukman
07-13-2001, 04:59 PM
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

webhost
07-13-2001, 05:08 PM
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>

webhost
07-13-2001, 05:12 PM
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
07-13-2001, 05:27 PM
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?

webhost
07-13-2001, 05:31 PM
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
07-13-2001, 05:50 PM
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?

webhost
07-13-2001, 07:42 PM
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
07-14-2001, 01:14 AM
Love this simple hack. Got it installed on my boards. Good job!

Lukman
07-14-2001, 02:52 AM
webhost mate - tried that = still no joy :(

I guess this hack doesnt wanna work on my board! ( sob sob)

Anybody got any other ideas?

webhost
07-14-2001, 03:24 AM
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!]

webhost
07-14-2001, 03:26 AM
lukman give a url to your board

ForzaGrifo
07-16-2001, 04:32 AM
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
07-17-2001, 03:35 PM
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

webhost
07-17-2001, 03:51 PM
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
07-20-2001, 04:56 AM
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

webhost
07-20-2001, 08:24 AM
<a href="http://www.vbulletin.com/forum/showthread.php?threadid=17116" target="_blank">http://www.vbulletin.com/forum/showt...threadid=17116</a>

Kengan
07-28-2001, 12:04 AM
Good Hack !! Like it ! ;)

ThomasP
08-02-2001, 08:12 PM
Works great!

TripleH
08-04-2001, 05:11 AM
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
08-09-2001, 09:31 PM
Cool hack ! I like it ! thanks ! Rocks !

webhost
08-09-2001, 10:16 PM
are you using vb 2.0.3

dilirum
08-19-2001, 11:42 AM
Works great for me... thanks.

LuBi
08-26-2001, 02:04 PM
Does this work in 2.0.3?

mjames
08-27-2001, 01:50 AM
Originally posted by LuBi
Does this work in 2.0.3?
You bet - here is a working example: http://sportscentralboards.com

eva2000
08-27-2001, 01:51 AM
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
10-13-2001, 12:49 AM
Is there any way to make it so it can display daily, Record, and Total?

Craig Armstrong
12-02-2001, 02:58 PM
Works Great. Thanks!

Bimma Boy
12-17-2001, 10:42 AM
Jus digged this up:D

Does this hack workon 2.2.1 guys? I think it does, as this site has thread views thingy.. I just wanna be sure that I have my hands on the right hack! ;)

Thanks all!

FWC
12-17-2001, 05:35 PM
Originally posted by Bimma Boy
Jus digged this up:D

Does this hack workon 2.2.1 guys? I think it does, as this site has thread views thingy.. I just wanna be sure that I have my hands on the right hack! ;)

Thanks all! Yes, it works on 2.2.1. :)

Michael2
01-05-2002, 04:41 PM
I know this has been mentioned but I just wanted to say that removing the space before and after the = sign got it to work for me. Before doing that I was getting parse errors. Just in case someone else has the same problem. Now it works great! Thanks!

Lucky
02-23-2002, 11:28 AM
Works great on 2.2.2